<?php
include_once 'header1.php';
?>
<script type="text/javascript">
function cleartbox()
{	
	document.getElementById("Sea_Sch").innerHTML="";
}
</script>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
function showSch(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("List").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("List").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","sch_names.php?q="+str,true);
xmlhttp.send();
}
function fillsch(val)
{
document.form1.SchName.value=val;
document.getElementById("List").innerHTML="";
}
</script>
<link rel="stylesheet" href="../css/datepicker.css" type="text/css" />
    <link rel="stylesheet" media="screen" type="text/css" href="../css/layout.css" />
  	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript" src="../js/datepicker.js"></script>
    <script type="text/javascript" src="../js/eye.js"></script>
    <script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/layout.js?ver=1.0.2"></script>
<script type="text/javascript">
function re_te()
{
var xmlhttp; 
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("tioptions").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","training_names.php",true);
xmlhttp.send();
}
function hide()
{
document.getElementById("tioptions").innerHTML="";
}

</script>
 <script type="text/javascript">
function showData(str,user)
{
document.getElementById("val").innerHTML="";
var xmlhttp;    
if (str=="Select One")
  {
  document.getElementById("searchres_adv").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("searchres_adv").innerHTML=xmlhttp.responseText;
    }
  }
  str=str+","+user;
xmlhttp.open("GET","get.php?q="+str,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function cleartbox(name)
{
	var name=name;	
	document.getElementById("searchres_adv").innerHTML="";
	document.getElementById("val").innerHTML="";
	if(name=="texthint")
	{
		document.getElementById("Listadv").innerHTML="";
		var text=document.forms["form1"]["texthint"].value;
		if(text=="Search Keywords")
		{
			document.getElementById(name).value="";	
			document.getElementById("List").innerHTML="";
		}
		document.getElementById("texthintadv").value="Search Keywords";
		var ope="true";		
var xmlhttp;    
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("operator").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getoper.php?q="+ope,true);
xmlhttp.send();
	}
	if(name=="texthintadv")
	{
		document.getElementById("List").innerHTML="";
		var textadv=document.forms["form2"]["texthintadv"].value;
		if(textadv=="Search Keywords")
		{
			document.getElementById(name).value="";	
			document.getElementById("Listadv").innerHTML="";
		}
		document.getElementById("texthint").value="Search Keywords";
var ope="true";		
var xmlhttp;    
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("operator").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getoper.php?q="+ope,true);
xmlhttp.send();
}
		
}
</script>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
function showHint(str)
{
var xmlhttp;    
if (str=="Search Keywords")
  {
  document.getElementById("List").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("List").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","gethint.php?q="+str,true);
xmlhttp.send();
}
function fill(val)
{
document.form1.texthint.value=val;
document.getElementById("List").innerHTML="";
}
</script>
<script type="text/javascript">
function showHintadv(str)
{
var xmlhttp;    
if (str=="Search Keywords")
  {
  document.getElementById("Listadv").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("Listadv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","gethintadv.php?q="+str,true);
xmlhttp.send();
}
function filladv(valadv)
{
document.form2.texthintadv.value=valadv;
document.getElementById("Listadv").innerHTML="";
}
</script>
<script type="text/javascript">
function getResadv(hin,user)
{
	var xmlhttp;
	var hint;
		var opera=document.forms["form2"]["Adv_Search_operator"].value;
	if(opera=="More Than"||opera==">="||opera=="Less Than"||opera=="<="||opera=="Equal To")
   { 
	 var valu=document.forms["form2"]["value"].value;
	    hint=hin+","+opera+","+valu;
		document.getElementById("val").innerHTML="";
  }    
if (hin=="Search Keywords")
  {
  document.getElementById("searchres_adv").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("searchres_adv").innerHTML=xmlhttp.responseText;
    }
  }
  hint=hint+","+user;
xmlhttp.open("GET","getresadv.php?q="+hint,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function getRes(hin)
{

	var xmlhttp;    
if (hin=="Search Keywords")
  {
  document.getElementById("searchres_adv").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("searchres_adv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getres.php?q="+hin,true);
xmlhttp.send();
}
</script>


<script type="text/javascript">
function findpw(un)
{
var xmlhttp;    
if (un=="")
  {
  document.getElementById("password").innerHTML='<img src="images/alert.jpg" width="12" height="12"/><font color="red">Please enter your username!</font>';
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("password").innerHTML=xmlhttp.responseText;
    }
  }
 xmlhttp.open("GET","Login/findpw.php?q="+un,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function DeleteVarification(rownum,variables)
{
	var rownum=rownum;
	var id="Varifi";
var r=confirm("Are you sure to delete this?");
if(r==true)
{
document.getElementById(id).value=variables;
}
}
</script>

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="ckeditor/sample.js" type="text/javascript"></script>

<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
    <link rel="stylesheet" media="screen" type="text/css" href="css/layout.css" />
  	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/datepicker.js"></script>
    <script type="text/javascript" src="js/eye.js"></script>
    <script type="text/javascript" src="js/utils.js"></script>
    <script type="text/javascript" src="js/layout.js?ver=1.0.2"></script>
<script type="text/javascript" src="popup-window.js"></script>
<script type="text/javascript">
function showNextPosts(pno)
{
var xmlhttp;    
if (pno=="")
  {
  document.getElementById("posts").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("posts").innerHTML=xmlhttp.responseText;
    }
  }
 xmlhttp.open("GET","nextposts.php?q="+pno,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}


function showProgress(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("progress").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("progress").innerHTML=xmlhttp.responseText;
    }
  }
 xmlhttp.open("GET","Login/getprogress.php?q="+str,true);
xmlhttp.send();
}
</script>


<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
	var img = document.images['captchaimg'];
	img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="ckeditor/sample.js" type="text/javascript"></script>

<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
    <link rel="stylesheet" media="screen" type="text/css" href="css/layout.css" />
  	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/datepicker.js"></script>
    <script type="text/javascript" src="js/eye.js"></script>
    <script type="text/javascript" src="js/utils.js"></script>
    <script type="text/javascript" src="js/layout.js?ver=1.0.2"></script>
<script type="text/javascript" src="popup-window.js"></script>
<script type="text/javascript">
function ImgDeleteVerification(image)
{
	var rownum=rownum;
	var id="del_Image_name";
var r=confirm("Are you sure to delete this?");
if(r==true)
{
document.getElementById(id).value=image;
}
}
</script>
<style>
.del_photo green close{margin:auto auto;text-align:center;width:200px;height:60px;color:#FFFFFF;background-color:#006699;border:#003366 1px solid;cursor:pointer;}
</style>
<script type="text/javascript">
function get_photo_to_delete(name,id)
{
var xmlhttp;
var set_no=document.forms["dele_photo"]["set_num"].value;
if(id=="back")
  {
   var name=name+"_back";
  }
   if(id=="next")
  {
   var name=name+"_next";
  }     
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("pop_up").innerHTML=xmlhttp.responseText;
    }
  }
var name=name+"_"+set_no;
xmlhttp.open("GET","del_photo_popup.php?q="+name,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function get_del_popup(name)
{
var xmlhttp;    
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("pop_up").innerHTML=xmlhttp.responseText;
    }
  }
  var name=name+"_start_1";
 xmlhttp.open("GET","del_photo_popup.php?q="+name,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function getContent(con)
{
var xmlhttp;    
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("getcontent").innerHTML=xmlhttp.responseText;
    }
  }
 xmlhttp.open("GET","getcontent.php?q="+con,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function showNextPosts(pno)
{
var xmlhttp;    
if (pno=="")
  {
  document.getElementById("posts").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("posts").innerHTML=xmlhttp.responseText;
    }
  }
 xmlhttp.open("GET","nextposts.php?q="+pno,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function submitmail()
{
var To=document.forms["myform"]["MailTo"].value;
var From=document.forms["myform"]["MailFrom"].value;
var Subject=document.forms["myform"]["Subject"].value;
var Message=document.forms["myform"]["Message"].value;
if (To=="")
  {
  alert("Please type the recipient's mail address!");
  return false;
  }
  else if (From=="")
  {
  alert("Please type the your mail address!");
  return false;
  }
  else
  {
  if (Message=="")
  {
 var rm=confirm("Your Message is empty,Do you allow empty mail?");
if (rm==true)
{
  if (Subject=="")
  {
var r=confirm("Your subject is empty,Do you allow without subject?");
if (r==true)
{
  return true;
}
if (r==false)
{
   return false;
}
 }
 else
  {
  return true;
  }
}
if (rm==false)
{
   return false;
}
}
else
{
if (Subject=="")
  {
var r=confirm("Your subject is empty,Do you allow without subject?");
if (r==true)
{
  return true;
}
if (r==false)
{
   return false;
}
 }
 else
  {
  return true;
  }
}
  }
}
</script>
<script type="text/javascript">
function showDeltable(tab)
{
var xmlhttp;    
if (tab=="")
  {
  document.getElementById("DelTable").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("DelTable").innerHTML=xmlhttp.responseText;
    }
  }
 xmlhttp.open("GET","getdeltable.php?q="+tab,true);
xmlhttp.send();
}
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
	<script type="text/javascript" src="<?php echo "$basedir";?>/js/fisheye-iutil.min.js"></script>
	
<script src="<?php echo "$basedir";?>/js/jquery.min.js"></script>
	<script src="<?php echo "$basedir";?>/js/slides.min.jquery.js"></script>
	<script>
		$(function(){
			$('#slides').slides({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 5000,
				pause: 2500,
				hoverPause: true,
				animationStart: function(current){
					$('.caption').animate({
						bottom:-35
					},100);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$('.caption').animate({
						bottom:0
					},200);
				}
			});
		});
	</script>
	<script type="text/javascript">
function DeleteVerification(rownum,veriables)
{
	var rownum=rownum;
	var id="Verifi";
var r=confirm("Are you sure to delete this?");
if(r==true)
{
document.getElementById(id).value=veriables;
}
}
</script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include_once ("Login/databaseconnection.php");

$get_all_photos=mysql_query("SELECT * FROM photos");
if($get_all_photos)
{
while($r_pap=mysql_fetch_array($get_all_photos))
{
$pho=$r_pap['Photo'];
if(!file_exists("img/".$pho)&&!file_exists("../img/".$pho))
      {
	 mysql_query("DELETE FROM photos WHERE Photo='".$pho."'");
	  }
}
}

date_default_timezone_set("Europe/Paris");
$t_d=date("Y-m-d");
if($_GET['action']=="forget_pw"&&$_SESSION['successfp']!="succ")
{
if(isset($_POST['Reset']))
{
require_once ("Login/forgotpw.php");
}
}
else if($_GET['action']=="acc_setting"&&$_SESSION['successacc']!="succ")
{
 if(isset($_POST['Register']))
{
require_once 'Login/accsett.php';
}
}
else if($_GET['action']=="pri_setting"&&$_SESSION['successpri']!="succ")
{
if(isset($_POST['Register']))
{
require_once 'Login/prisett.php';
}
}
else if($_GET['action']=="create"&&$_SESSION['successcre']!="succ")
{
if(!empty($errors))
{
echo "<p class='err'>".nl2br($errors)."</p>";
}
	if(isset($_POST['Register']))
{
$cap=$_POST['6_letters_code'];
$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$NIC_Number=$_POST['NIC_Number'];
$E_Mail=$_POST['E_Mail'];
$Login_Username=$_POST['Login_Username'];
$Password=$_POST['Password'];
$PasswordVar=$_POST['PasswordVar'];
$Access_Type=$_POST['Access_Type'];

if($First_Name==""||$Last_Name==""||$NIC_Number==""||$E_Mail==""||$Login_Username==""||$Password=="")
	{
	$_SESSION['errorin']="All details are required,Please fill all!";
    } 
if($First_Name!=""&&$Last_Name!=""&&$NIC_Number!=""&&$E_Mail!=""&&$Login_Username!=""&&$Password!="")
	{
	if($cap=="")
{
$_SESSION['errors']= "\n Please type the captcha code!";
}
else
{
	if(empty($_SESSION['6_letters_code'] ) ||
	  strcmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
	{
		$errors .= "\n The captcha code does not match!";
	}
	
	if(empty($errors))
	{
		require_once 'Login/REG.php';
	}
$_SESSION['errors'].=$errors;
}
}
}
}
if(loggedin()||$_GET['action']=="forget_pw")
{
  if(isset($_POST['dele']))
  {
   $action="delete";
   }
   
   if($action=="delete")
{
$dveri=$_POST['Verifi'];
if($dveri!="")
{
$veri=explode(",",$dveri);
$Post_Id=$veri['0'];
}
if($dveri!="")
{
$resultdel=mysql_query("DELETE FROM posts WHERE Post_Id='".$Post_Id."'");
if($resultdel)
{
$Pos_Id="POS0000";
$all_posts=mysql_query("SELECT * FROM posts");
while($pos_row=mysql_fetch_array($all_posts))
{
$po_id=$pos_row['Post_Id'];
$lastpost_id=substr("$Pos_Id",3);
$nextpost_id=($lastpost_id+1);
$r=(strlen($lastpost_id)-strlen($nextpost_id));
$Pos_Id='POS';
if(strlen($nextpost_id)<strlen($lastpost_id))
{
for($i=0;$i<(strlen($lastpost_id)-strlen($nextpost_id));$i++)
{
$Pos_Id=$Pos_Id.'0';
}
$Pos_Id=$Pos_Id.$nextpost_id;
}
else
{
$Pos_Id=$Pos_Id.$nextpost_id;
}
$upp_photos=mysql_query("UPDATE posts SET Post_Id='$Pos_Id' WHERE Post_Id='$po_id'");
}
$_SESSION['del']="The post is successfully deleted!";
}
if(!$resultdel)
{
$_SESSION['del']="Sorry unable to delete this post!";
}
}
  }
if((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']=="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']=="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']=="succ"))||!isset($_GET['action'])||($_GET['action']!="create"&&$_GET['action']!="forget_pw"&&$_GET['action']!="pri_setting"&&$_GET['action']!="acc_setting"))
{
	if(isset($_POST['UploadPhoto']))
{
	require_once 'img_upload.php';
}
if(isset($_POST['Delete']))
	   {
	   if($_GET['action']=="delete")
	      {
	   	require_once ("Competition/dcom.php");
		}
	   
	   if($_GET['action']=="deletee")
	   {
	   	require_once ("Exams/dexam.php");
		
	   }
	   if($_GET['action']=="deletep")
	   {
	   	require_once ("Programmes/dpro.php");
		
	   }
	   if($_GET['action']=="deletel")
	   {
	   	require_once ("Lab/dlab.php");
		
	   }
	   if($_GET['action']=="deleter")
	   {
	   	require_once ("Resources/dres.php");
		
	   }
	   if($_GET['action']=="deletert")
	   {
	   	require_once ("Resourceteam/drestea.php");
		
	   } if($_GET['action']=="deletes")
	   {
	   require_once ("Schools/asch.php");
	   }
	   if($_GET['action']=="deletetd")
	   {
	   require_once ("Trainingdetails/atrai.php");
	   }
	   if($_GET['action']=="deletet")
	   {
	   require_once ("Teachers/atea.php");
	   } 
}
?>
<?php
if(isset($_POST['Add']))
	   {
	   if($_GET['action']=="adds")
	   {
	   require_once ("Schools/asch.php");
	   }
	   if($_GET['action']=="addtd")
	   {
	   require_once ("Trainingdetails/atrai.php");
	   }
	   if($_GET['action']=="addt")
	   {
	   require_once ("Teachers/atea.php");
	   }
	   if($_GET['action']=="add")
	   {
	   require_once ("Competition/acom.php");
	   }
	   if($_GET['action']=="adde")
	   {
	   	require_once ("Exams/aexam.php");
		
	   }
	   if($_GET['action']=="addp")
	   {
	   	require_once ("Programmes/apro.php");
		
	   }
	   if($_GET['action']=="addl")
	   {
	   	require_once ("Lab/alab.php");
		
	   }
	  if($_GET['action']=="addr")
	   {
	   	require_once ("Resources/ares.php");
		
	   }
	   if($_GET['action']=="addrt")
	   {
	   	require_once ("Resourceteam/arestea.php");
		}
	   }
	   if(isset($_POST['SendMail']))
{
$tos=$POST['MailTo'];
$subjects=$POST['Subject'];
$message=$POST['Message'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=utf-8" . "\r\n";
$headers .= 'From:""' . "\r\n";

$txt1=str_replace("[s","[font s",$message);
$txt2=str_replace("[c","[font c",$txt1);
$txt3=str_replace("[/size]","[/font]",$txt2);
$txt4=str_replace("[/color]","[/font]",$txt3);
$s1=str_replace("[","<",$txt4);
$final_message=str_replace("]",">",$s1);
mail($tos,$subjects,$final_message,$headers);
}
}
}
?>

<?php
if((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']=="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']=="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']=="succ"))||!isset($_GET['action'])||($_GET['action']!="create"&&$_GET['action']!="forget_pw"&&$_GET['action']!="pri_setting"&&$_GET['action']!="acc_setting"))
{
if(!loggedin())
{
				$username="";
				$password="";
				if(isset($_POST['Login']))
				{
				$username= $_POST['username'];
				$password= $_POST['password'];		
				}
				if(isset($_POST['Login'])&&($username!=""&&$password!=""))
				{
				require_once 'Login/Loginvali.php';
				}
				else if(isset($_POST['Login'])&&($username==""||$password==""))
				{
				$_SESSION['error1']="Please enter the Username & Password!";
				}
				}
}
		?>
<?php
include_once 'header2.php';
?>

<?php
if(loggedin())
{
?>
<li><a href="<?php echo "$basedir";?>/index.php" class="active"><font style="text-shadow:#969" size="+1">Home</font></a></li>
				<li><a href="<?php echo "$basedir";?>/Schools/Schools.php"><font style="text-shadow:#969" size="+1">Schools</font></a>
               
          </li>
				<li><a href="#"><font style="text-shadow:#969" size="+1">Staff</font></a>
                <ul>
            <li><a href="<?php echo "$basedir";?>/Teachers/teachers.php"><font style="text-shadow:#969" size="2">School Teachers</font></a></li>
            <li><a href="<?php echo "$basedir";?>/Resourceteam/resourceteam.php"><font style="text-shadow:#969" size="2">Resource Team</font></a></li>
           <li><a href="<?php echo "$basedir";?>/Trainingdetails/Trainingdetails.php"><font style="text-shadow:#969" size="2">Trained Teachers</font></a></li>
		    <li><a href="<?php echo "$basedir";?>/non_academic_staff.php"><font style="text-shadow:#969" size="2">Non Academic Staff</font></a></li>
            </ul></li>
				<li><a href="<?php echo "$basedir";?>/Lab/Labs.php"><font style="text-shadow:#969" size="+1">Labs</font></a>
				<ul><li><a href="<?php echo "$basedir";?>/Lab/Labs.php"><font style="text-shadow:#969" size="2">Labs</font></a></li>
				<li><a href="<?php echo "$basedir";?>/Resources/Resources.php"><font style="text-shadow:#969" size="2">Resources</font></a></li>
				</ul></li>				
				<li><a href="<?php echo "$basedir";?>/students.php"><font style="text-shadow:#969" size="+1">Students</font></a></li>
				<li><a href="<?php echo "$basedir";?>/Exams/Exams.php"><font style="text-shadow:#969" size="+1">Curriculum</font></a><ul>
                <li><a href="<?php echo "$basedir";?>/Exams/Exams.php"><font style="text-shadow:#969" size="2">Exams</font></a></li>
                <li><a href="<?php echo "$basedir";?>/Programmes/Programmes.php"><font style="text-shadow:#969" size="2">Programmes</font></a></li>
                <li><a href="<?php echo "$basedir";?>/Competition/Competition.php"><font style="text-shadow:#969" size="2">Competitions</font></a></li></ul></li>
               <li><a href="#"><font style="text-shadow:#969" size="4">Settings</font></a>
                <ul>
            <li><a href="?action=acc_setting"><font style="text-shadow:#969" size="2"><strong>Account Settings</strong></font></a></li>
            <li><a href="?action=pri_setting"><font style="text-shadow:#969" size="2"><strong>Privacy Settings</strong></font></a></li>
          </ul></li>
			</ul>
		</div>
<?php
 }
 ?>
</div>
<?php
if(!loggedin())
{
if((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']=="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']=="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']=="succ"))||!isset($_GET['action'])||($_GET['action']!="create"&&$_GET['action']!="forget_pw"&&$_GET['action']!="pri_setting"&&$_GET['action']!="acc_setting"))
{
?>
<div id="content">
	<div id="main">
	  <div id="welcome"> <table width="896" height="353" border="0">
           
		        <tr>
		          <td height="41" colspan="2"><h2>Welcome to Schools Management System!</h2></td>
		          <td>&nbsp;</td>
		          <td></td>
          </tr>
		        <tr>
		          <td colspan="2"><div id="example">
      <div id="example2">
        <div id="slides">
          <div class="slides_container">
		  <?php
require_once ("Login/config.php");
include_once ("Login/databaseconnection.php");
$getimg=mysql_query("SELECT * FROM photos");
$i_no=0;
while($rowpho=mysql_fetch_array($getimg))
{
$getphid=mysql_query("SELECT MAX(Photo_Id) AS Max_P_Id FROM photos");
if($g_p_id=mysql_fetch_array($getphid))
{
$MaxP_Id=$g_p_id['Max_P_Id'];
}
$ph_num=substr("$MaxP_Id",2);
$P_inn=($ph_num-$i_no);
$r=(strlen($ph_num)-strlen($P_inn));
$MP_Id='PH';
if(strlen($P_inn)<strlen($ph_num))
{
for($i=0;$i<(strlen($ph_num)-strlen($P_inn));$i++)
{
$MP_Id=$MP_Id.'0';
}
$MP_Id=$MP_Id.$P_inn;
}
else
{
$MP_Id=$MP_Id.$P_inn;
}
if($i_no<7)
{
$getphoto=mysql_query("SELECT * FROM photos WHERE Photo_Id='$MP_Id'");
if($rowphoto=mysql_fetch_array($getphoto))
{
$img=$rowphoto['Photo'];
}
$i_no++;
?>
<div class="slide"><img src="<?php echo $basedir;?>/img/<?php echo $img;?>" width="570" height="270" alt="Slide <?php echo $i_no;?>" /></div>
<?php
}

}
?>
          </div>
          <a href="#" class="prev"><img src="<?php echo $basedir;?>/img/arrow-prev.png" width="24" height="43" alt="Arrow Prev" /></a> <a href="#" class="next"><img src="<?php echo $basedir;?>/img/arrow-next.png" width="24" height="43" alt="Arrow Next" /></a></div>
        <img src="<?php echo $basedir;?>/img/example-frame.png" width="592" height="291" alt="Example Frame" id="frame" align="top"/></div>
    </div></td>
		        <td width="12">&nbsp;</td>
		        <td width="251" height="306"><marquee direction="up" height="290"  style="marquee-speed:slow"><p align="center"><font color="#930049" id="f_si" face="Verdana, Geneva, sans-serif">Schools management system for Northern province</font><br/><br/>
    </p>
    <p><font color="#CC66CC" size="3" id="f_si1" face="Times New Roman, Times, serif">This system was developed only for the ICT department of the education department of northern province.But this system will modify to other departments soon.</font></p></marquee></td>
          </tr>
            </table><br/><br/>
  	<div id="examplepage">  
<div id="contacts" class="boxed">
<br/><br/><br/>
	  <div id="side">
		<div class="boxtop"></div>
		<div class="box">
		  <h3>Our Contact Details !</h3>
			<a href="#">
			<span class="item">
			<span class="sidedate"><font size="2">E_Mail:</font><br/><span><font size="1">CONTACT</font></span></span>
						<strong>edudpt@gmail.com</strong></span>
			</a>
			<a href="#">
			<span class="item">
			<span class="sidedate"><font size="2">Block:</font><br/>
			<span><font size="1">CONTACT</font></span></span>
						<strong>www.edudpt.blogspot.com</strong></span>
	      </a><span class="item last">
			Tp Number:021 568656<br/>
			Address:Copay road,Maruthanarmadam.<br/>
			Fax:4646745756</span>
	     
		  </div>
		<!-- end div .box -->
				<div class="boxbottom"></div>
		</div>
		<div id="getcontent">
		<ul id="feature_menu">
		<li><input class="current" type="button" id="did_you_know" onClick="getContent(this.id)" value="DID YOU KNOW..." class="advbutton"/></li>
				<li><input type="button" id="on_this_day" onClick="getContent(this.id)" value="ON THIS DAY..." class="advbutton"/></li>
				<li><input type="button" id="featured_content" onClick="getContent(this.id)" value="FEATURED CONTENT..." class="advbutton"/></li>
				</ul>
			<div id="feature">
				<img src="<?php echo "$basedir";?>/images/header_images.jpg" height="148" width="278" />
        <?php
		echo '<p class="text">This system allows you to access data only if you logged in this system,because of the security purpose.If you did not have username and password you can create an account.</p>';
		?>
		</div>
		</div>
      </div>
    </div>
</div>

</div>
	</div>
	<div id="sidebar_login">
		<div id="login" class="boxed">
			<h2 class="title">Login</h2>
			<div class="content">
            <form action="<?php echo "$basedir";?>/index.php" method="POST" name="Login">
			  <table width="100%" height="18" border="0">
		        <tr>
		          <td height="14" class="err"><?php 

				if(isset($_POST['Login'])) 
				{
				if(isset($_SESSION['error1']))
				{
					echo '<img src="images/alert.png" width="12" height="12"/> ';
				echo $_SESSION['error1'];
				unset($_SESSION['error1']);
				}
			}
?>
</td>
	            </tr>
	          </table>
		      <table border="0">
			      <tr>
			        <td width="66" height="37" class="text"><h4>Username:</h4></td>
			        <td width="0">&nbsp;</td>
			        <td colspan="3"><input type="text" name="username"/></td>
		        </tr>
			      <tr>
			        <td height="38" class="text"><h4>Password:</h4></td>
			        <td>&nbsp;</td>
			        <td colspan="3"><input type="password" name="password"/></td>
		        </tr>
			      <tr>
			        <td height="24">&nbsp;</td>
			        <td>&nbsp;</td>
			        <td width="58"></td>
			        <td width="100"><input type="submit" class="login_button" name="Login" value="" /></td>
			        <td width="8">&nbsp;</td>
                </tr>
                <tr>
                <td height="22" colspan="2" align="center" bgcolor="#993366"><a href="?action=create">Sign Up</a></td>
                <td height="22">&nbsp;</td>
                <td height="22" colspan="2" bgcolor="#993366"><a href="?action=forget_pw">Forget Password</a></td>
    </tr>
		      </table>
              </form>
			</div>
		</div>
		<div id="updates" class="boxed">
			<h2 class="title">Recent Updates</h2>
			<div class="content">
				<ul>
				<div id="posts">
					<?php
				$get_posts=mysql_query("SELECT * FROM posts");
				$num=mysql_num_rows($get_posts);
				if($get_posts)
				{
				for($i=0;$i<4;$i++)
				{
				if($rowpost=mysql_fetch_array($get_posts))
				{
				echo '<li><h3>'.$rowpost['Event_Date'].'</h3>';
				echo '<p>'.$rowpost['News'].'&#8230;</p></li>';
				}
				}
				}
				if(mysql_num_rows($get_posts)>4)
				{
				$ind=5;
				?>
				<img src="images/next.png" align="right" onClick="showNextPosts(<?php echo $ind;?>)"/>
				<?php
              	}
				?>
</div>
</ul>
</div>
</div>
	
	</div>
	<?php
	}
	}
	?>
	<?php
if(loggedin()||$_GET['action']=="forget_pw")
{
if((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']=="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']=="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']=="succ"))||!isset($_GET['action'])||($_GET['action']!="create"&&$_GET['action']!="forget_pw"&&$_GET['action']!="pri_setting"&&$_GET['action']!="acc_setting"))
{
$photo_name=$_POST['del_Image_name'];
if($photo_name!="")
{
if(file_exists("img/".$photo_name))
{
$do = unlink("img/$photo_name"); 
if($do=="1")
{
$Photo_Delete=mysql_query("DELETE FROM photos WHERE Photo='$photo_name'");
if($Photo_Delete)
{
$Pho_Id="PH0000";
$all_photos=mysql_query("SELECT * FROM photos");
while($pho_row=mysql_fetch_array($all_photos))
{
$phot_id=$pho_row['Photo_Id'];
$last_id=substr("$Pho_Id",2);
$next_id=($last_id+1);
$r=(strlen($last_id)-strlen($next_id));
$Pho_Id='PH';
if(strlen($next_id)<strlen($last_id))
{
for($i=0;$i<(strlen($last_id)-strlen($next_id));$i++)
{
$Pho_Id=$Pho_Id.'0';
}
$Pho_Id=$Pho_Id.$next_id;
}
else
{
$Pho_Id=$Pho_Id.$next_id;
}
$upp_photos=mysql_query("UPDATE photos SET Photo_Id='$Pho_Id' WHERE Photo_Id='$phot_id'");
}
$_SESSION['Photo_Delete']="Photo is successfully deleted!";
}
if(!$Photo_Delete)
{
$_SESSION['Photo_Delete']="Sorr,unable to delete the photo!";
}
} 
else 
{ 
$_SESSION['Photo_Delete']="There was an error trying to delete the photo!"; 
} 
}
else 
{ 
$Photo_Exis=mysql_query("SELECT * FROM photos WHERE Photo='$photo_name'");
if($Photo_Exis)
{
if(mysql_num_rows($Photo_Exis)>0)
{
$Photo_Delete=mysql_query("DELETE FROM photos WHERE Photo='$photo_name'");
}
$_SESSION['Photo_Delete']=$photo_name." is not exists!"; 
} 
}
}
}
if(isset($_POST['AddNews']))
{
$Date=$_POST['Date'];
$News=$_POST['News'];
if($Date==""&&$News=="")
{
$_SESSION['errornews']="Please enter the Date and the news!";
}
else if($Date==""&&$News!="")
{
$_SESSION['errornews']="Please enter the Date!";
}
else if($Date!=""&&$News=="")
{
$_SESSION['errornews']="Please type the news!";
}
else
{
$getpostid=mysql_query("SELECT MAX(Post_Id) AS Max_P_Id FROM posts");
if($g_p_id=mysql_fetch_array($getpostid))
{
$Max_Id=$g_p_id['Max_P_Id'];
if($Max_Id=="")
{
$M_Id="POS0001";
}
else
{
$inum=substr("$Max_Id",3);
$inn=($inum+1);
$r=(strlen($inum)-strlen($inn));
$M_Id='POS';
if(strlen($inn)<strlen($inum))
{
for($i=0;$i<(strlen($inum)-strlen($inn));$i++)
{
$M_Id=$M_Id.'0';
}
$M_Id=$M_Id.$inn;
}
else
{
$M_Id=$M_Id.$inn;
}
}
}
$txtNews=str_replace("[s","[font s",$News);
$txtNews2=str_replace("[c","[font c",$txtNews);
$txtNews3=str_replace("[/size]","[/font]",$txtNews2);
$txtNews4=str_replace("[/color]","[/font]",$txtNews3);
$News1=str_replace("[","<",$txtNews4);
$final_News=str_replace("]",">",$News1);
$Posted_By=$_SESSION['NIC_Number'];
$addnews=mysql_query("INSERT INTO posts(Post_Id,Event_Date,News,Posted_By,Posted_Date) VALUES('$M_Id','$Date','$final_News','$Posted_By','$t_d')");
if($addnews)
{
$_SESSION['add_news']="The news is successfully added!";
}
if(!$addnews)
{
$_SESSION['add_news']="Unable to add the news!";
}
}
}
}
?>
	<div id="content_login">
	<div id="main">
	  <div id="bodyfield">
<?php
$User_Type=$_SESSION['Access_Type'];
if(((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||$_GET['action']=="reg_tea")&&$_SESSION['OK']!="OK")&&($User_Type=="Teacher in Charge"||$User_Type=="Teacher"))
{
//to save teacher's details
$T_NIC_Number=$_GET['T_NIC_Number'];
$First_Name=$_SESSION['First_Name'];
$Last_Name=$_SESSION['Last_Name'];
$Appointment_Date=$_POST['Appointment_Date'];
$New_Role=$_POST['New_Role'];
$Role=$_POST['Role'];
$Res_Team=$_POST['Res_Team'];
$From_Date=$_POST['From_Date'];
$Date_Of_Birth=$_POST['Date_Of_Birth'];
$New_Specialised_In=$_POST['New_Specialised_In'];
$Training_Name=$_POST['Training_Name'];
$From_Date=$_POST['From_Date'];
$SchName=$_POST['SchName'];
$Gender=$_POST['Gender'];
$Nature_Of_Appointment=$_POST['Nature_Of_Appointment'];
$Service=$_POST['Service'];
$Specialised_In=$_POST['Specialised_In']; 
$Professional_Qualifications=$_POST['Professional_Qualifications'];
$Achievements=$_POST['Achievements_Awards'];
$Achieve= mysql_real_escape_string($Achievements);
$Address=$_POST['Address'];
$Mobile_Tp_Number=$_POST['Mobile_Tp_Number'];
$Home_Tp_Number=$_POST['Home_Tp_Number'];
$Office_Tp_Number=$_POST['Office_Tp_Number'];
$Appointed_Subject=$_POST['Appointed_Subject'];
date_default_timezone_set("Europe/Paris");
$t_d=date("Y-m-d");
if($From_Date=="")
{
$From_Date=$t_d;
}
	$name=explode(",",$SchName);
    $nam=$name[0];
$tn=count($name);
for($i=1;$i<$tn;$i++)
{
if(empty($adr))
{
$adr=$name[$i];
}
else
{
$adr=$adr.",".$name[$i];
}
}
$results= mysql_query("SELECT * FROM school Where Name='$nam' AND Address='$adr'");
if($row = mysql_fetch_array($results))
{
 $School_Id=$row['School_Id'];
}
	date_default_timezone_set("Europe/Paris");
    $t_d=date("Y-m-d");
	if(isset($_POST['Register_Tea']))
	{
		$T_NIC_Number=$_POST['T_NIC_Number'];
 if($T_NIC_Number=="")
	   {
		  $_SESSION['errorin']="Please enter the NIC number,Indexed details are required!";
		   }
if($T_NIC_Number!="")
	   {
$Tea_Che=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC_Number'");
if($rowl=mysql_fetch_array($Tea_Che))
		{
			$_SESSION['errorexi']="Sorry this Teacher's record already exists";
		}		
		else
		{		
  $Role=$_POST['Role'];
$New_Role=$_POST['New_Role'];
if($Role==""&&$New_Role=="")
{
$Role="Teacher";
}
else if($New_Role!=""&&$Role!="")
{
$_SESSION['error']="Please select or type the role!";
}
else
{
if($New_Role!="")
{
$Role=$New_Role;
}
 $reg_Specia_In="";
 for($i=0;$i<sizeof($Specialised_In);$i++)
  {
  if(empty($reg_Specia_In))
  {
  $reg_Specia_In=$Specialised_In[$i];
  }
  else
  {
  $reg_Specia_In=$reg_Specia_In.",".$Specialised_In[$i];
  }
  }
  if($New_Specialised_In!="")
  {
  if(empty($reg_Specia_In))
  {
  $reg_Specia_In=$New_Specialised_In;
  }
  else
  {
  $reg_Specia_In=$reg_Specia_In.",".$New_Specialised_In;
  }
  }
  if(empty($reg_Specia_In))
  {
  $reg_Specia_In="";
  }
	$name=explode(",",$SchName);
    $nam=$name[0];
$tn=count($name);
for($i=1;$i<$tn;$i++)
{
if(empty($adr))
{
$adr=$name[$i];
}
else
{
$adr=$adr.",".$name[$i];
}
}
$results= mysql_query("SELECT * FROM school Where Name='$nam' AND Address='$adr'");
if($row = mysql_fetch_array($results))
{
 $School_Id=$row['School_Id'];
}
if($Service=="")
{
$serv="0year";
}
if($Service!="")
{
$chars = str_split( $Service );
  $i=0;
while($i<strlen($Service))
{
$c=$chars[$i]; 
if($c=="y"||$c=="Y")
{
$st=$i;
break;
}
else
{
$i++;
}
}
if($st>0)
{
$ser=substr($Service,0,$st);
$ser_chars=str_split($ser);
for($i=0;$i<count($ser_chars);$i++)
{
if($ser_chars[$i]!="0"&&$ser_chars[$i]!="1"&&$ser_chars[$i]!="2"&&$ser_chars[$i]!="3"&&$ser_chars[$i]!="4"&&$ser_chars[$i]!="5"&&$ser_chars[$i]!="6"&&$ser_chars[$i]!="7"&&$ser_chars[$i]!="8"&&$ser_chars[$i]!="9")
{
$ser="0";
}
}
}
if($st==0)
{
$ser="0";
}
if($st=="")
{
$ser_chars=str_split($Service);
for($i=0;$i<count($ser_chars);$i++)
{
if($ser_chars[$i]!="0"&&$ser_chars[$i]!="1"&&$ser_chars[$i]!="2"&&$ser_chars[$i]!="3"&&$ser_chars[$i]!="4"&&$ser_chars[$i]!="5"&&$ser_chars[$i]!="6"&&$ser_chars[$i]!="7"&&$ser_chars[$i]!="8"&&$ser_chars[$i]!="9")
{
$ser="0";
}
else
{
$ser=$Service;
}
}
}
if((int) $ser>1)
{
$serv=$ser."years";
}
if((int) $ser<=1)
{
$serv=$ser."year";
}
}
if($Res_Team=="")
{
$Res_Team="No";
}
$Training_Name=$_POST['Training_Name'];
$tra_id=mysql_query("SELECT * FROM training WHERE Training_Name='".$Training_Name."'");
if($r_id=mysql_fetch_array($tra_id))
{
$Training_Id=$r_id['Training_Id'];
}
$maxid=mysql_query("SELECT max(Member_Id) as maxId FROM resource_team");
while($rowid=mysql_fetch_array($maxid))
{
$m_Id=$rowid['maxId'];
 $inum=substr("$m_Id",1);
$inn=($inum+1);
$Member_Id='M';
if(strlen($inn)<strlen($inum))
{
for($i=0;$i<(strlen($inum)-strlen($inn));$i++)
{
$Member_Id=$Member_Id.'0';
}
$Member_Id=$Member_Id.$inn;
}
else
{
$Member_Id=$Member_Id.$inn;
}
}
$From_Date=$_POST['From_Date'];
$dehol="";
$Academic_Qualifications=$_POST['Academic_Qualifications'];
date_default_timezone_set("Europe/Paris");
    $t_d=date("Y-m-d");
$Profe_Qualifications= mysql_real_escape_string($Professional_Qualifications);
if($T_NIC_Number!=""&&$SchName!=""&&$First_Name!=""&&$Last_Name!=""&&$Date_Of_Birth!=""&&$Gender!=""&&$Nature_Of_Appointment!=""&&$Academic_Qualifications!=""&&$Service!=""&&$Address!=""&&$Appointment_Date!=""&&$Appointed_Subject!="")
{
$A_Qua="";
if($Res_Team=="No")
{
for($i=0;$i<sizeof($Academic_Qualifications);$i++)
  {
   if($Academic_Qualifications[$i]=="Degree_holder")
  {
 $dehol="yes";
  $deg=$_POST['Academic_Qualifications_Deg'];
   $degree=mysql_real_escape_string($deg);
    if($degree=="")
  {
  $_SESSION['errordeg']="Please type your subject you got degree on it!";
  }
  else
  {
  if(empty($A_Qua))
  {
  $A_Qua="deg_".$degree;
  }
  else
  {
  $A_Qua=$A_Qua.",deg_".$degree;
  }
  }
  }
  else
  {
  if(empty($A_Qua))
  {
  $A_Qua=$Academic_Qualifications[$i];
  }
  else
  {
$A_Qua=$A_Qua.','.$Academic_Qualifications[$i];
}
}
}
if($dehol=="yes")
  {
  $deg=$_POST['Academic_Qualifications_Deg'];
   $degree=mysql_real_escape_string($deg);
    if($degree!="")
  {
$sql=mysql_query("INSERT INTO teacher(Specialised_In,Role,T_NIC_Number,School_Id,First_Name,Last_Name,Date_Of_Birth,Gender,Nature_Of_Appointment,Academic_Qualifications,Professional_Qualifications,Achievements_Awards,Service,Address,Mobile_Tp_Number,Home_Tp_Number,Office_Tp_Number,Appointment_Date,Appointed_Subject,Last_Updated_Date)VALUES('$reg_Specia_In','$Role','$T_NIC_Number','$School_Id','$First_Name','$Last_Name','$Date_Of_Birth','$Gender','$Nature_Of_Appointment','$A_Qua','$Profe_Qualifications','$Achieve','$serv','$Address','$Mobile_Tp_Number','$Home_Tp_Number','$Office_Tp_Number','$Appointment_Date','$Appointed_Subject','$t_d')");
if($sql)
  {
  $_SESSION['OK']="OK";
  $sqlrt=mysql_query("INSERT INTO resource_team(Training_Id,Member_Id,T_NIC_Number,From_Date,Last_Updated_Date)VALUES('$Training_Id','$Member_Id','$T_NIC_Number','$From_Date','$t_d')");
if($sqlrt)
  {
$_SESSION['errorrt']="Sorry unable to register this record into resource team!";
  }
if(!$sqlrt)
  {
$_SESSION['errorrt']="Sorry unable to register this record into resource team!";
  }
  $_SESSION['error']="This record is successfully registered!";
  
 }
if(!$sql)
  {
$_SESSION['error']="Sorry unable to register this record!";
  }
  }
  }
  else
  {
  $sql=mysql_query("INSERT INTO teacher(Specialised_In,Role,T_NIC_Number,School_Id,First_Name,Last_Name,Date_Of_Birth,Gender,Nature_Of_Appointment,Academic_Qualifications,Professional_Qualifications,Achievements_Awards,Service,Address,Mobile_Tp_Number,Home_Tp_Number,Office_Tp_Number,Appointment_Date,Appointed_Subject,Last_Updated_Date)VALUES('$reg_Specia_In','$Role','$T_NIC_Number','$School_Id','$First_Name','$Last_Name','$Date_Of_Birth','$Gender','$Nature_Of_Appointment','$A_Qua','$Profe_Qualifications','$Achieve','$serv','$Address','$Mobile_Tp_Number','$Home_Tp_Number','$Office_Tp_Number','$Appointment_Date','$Appointed_Subject','$t_d')");

if($sql)
  {
  $_SESSION['OK']="OK";
    $_SESSION['error']="This record is successfully registered!";
 }
if(!$sql)
  {
$_SESSION['error']="Sorry unable to register this record!";
  }

  }
}
if($Res_Team=="Yes")
{
if($Training_Id==""||$Member_Id==""||$From_Date=="")
{
$_SESSION['errorrt']="Sorry unable to register this record into resource team!";
}
else
{
for($i=0;$i<sizeof($Academic_Qualifications);$i++)
  {
   if($i==0)
  {
  if($Academic_Qualifications[$i]=="Degree_holder")
  {
  $dehol="yes";
  $deg=$_POST['Academic_Qualifications_Deg'];
   $degree=mysql_real_escape_string($deg);
    if($degree=="")
  {
  $A_Qua="deg_";
  $_SESSION['errordeg']="Please type your subject that you got degree on it!";
  }
  else
  {
  $A_Qua="deg_".$degree;
  }
  }
  else
  {
  $A_Qua=$Academic_Qualifications[$i];
  }
  }
  else
  {
  if($Academic_Qualifications[$i]=="Degree_holder")
  {
  $dehol="yes";
  $deg=$_POST['Academic_Qualifications_Deg'];
   $degree=mysql_real_escape_string($deg);
    if($degree=="")
  {
  $A_Qua=$A_Qua.",deg_";
  $_SESSION['errordeg']="Please type your subject that you got degree on it!";
  }
  else
  {
  $A_Qua=$A_Qua.",deg_".$degree;
  }
  }
  else
  {
$A_Qua=$A_Qua.','.$Academic_Qualifications[$i];
}
 }
}
if($dehol=="yes")
  {
  $deg=$_POST['Academic_Qualifications_Deg'];
   $degree=mysql_real_escape_string($deg);
    if($degree!="")
  {
$sql=mysql_query("INSERT INTO teacher(Specialised_In,Role,T_NIC_Number,School_Id,First_Name,Last_Name,Date_Of_Birth,Gender,Nature_Of_Appointment,Academic_Qualifications,Professional_Qualifications,Achievements_Awards,Service,Address,Mobile_Tp_Number,Home_Tp_Number,Office_Tp_Number,Appointment_Date,Appointed_Subject,Last_Updated_Date)VALUES('$reg_Specia_In','$Role','$T_NIC_Number','$School_Id','$First_Name','$Last_Name','$Date_Of_Birth','$Gender','$Nature_Of_Appointment','$A_Qua','$Profe_Qualifications','$Achieve','$serv','$Address','$Mobile_Tp_Number','$Home_Tp_Number','$Office_Tp_Number','$Appointment_Date','$Appointed_Subject','$t_d')");
if($sql)
  {
  $_SESSION['OK']="OK";
   $_SESSION['error']="This record is successfully registered!";
  $sqlrt=mysql_query("INSERT INTO resource_team(Training_Id,Member_Id,T_NIC_Number,From_Date,Last_Updated_Date)VALUES('$Training_Id','$Member_Id','$T_NIC_Number','$From_Date','$t_d')");
if($sqlrt)
  {
 $_SESSION['error']="This record is successfully registered!";
  }
if(!$sqlrt)
  {
 $_SESSION['error']= $_SESSION['error']." Sorry unable to register this record into resource team!";
  }
 }
if(!$sql)
  {
$_SESSION['error']="Sorry unable to register this record!";
  }
  }
  }
  else
  {
  $sql=mysql_query("INSERT INTO teacher(Specialised_In,Role,T_NIC_Number,School_Id,First_Name,Last_Name,Date_Of_Birth,Gender,Nature_Of_Appointment,Academic_Qualifications,Professional_Qualifications,Achievements_Awards,Service,Address,Mobile_Tp_Number,Home_Tp_Number,Office_Tp_Number,Appointment_Date,Appointed_Subject,Last_Updated_Date)VALUES('$reg_Specia_In','$Role','$T_NIC_Number','$School_Id','$First_Name','$Last_Name','$Date_Of_Birth','$Gender','$Nature_Of_Appointment','$A_Qua','$Profe_Qualifications','$Achieve','$serv','$Address','$Mobile_Tp_Number','$Home_Tp_Number','$Office_Tp_Number','$Appointment_Date','$Appointed_Subject','$t_d')");
if($sql)
  {
  $_SESSION['OK']="OK";
  $_SESSION['error']="This record is successfully registered!";
  $sqlrt=mysql_query("INSERT INTO resource_team(Training_Id,Member_Id,T_NIC_Number,From_Date,Last_Updated_Date)VALUES('$Training_Id','$Member_Id','$T_NIC_Number','$From_Date','$t_d')");
if($sqlrt)
  {
 $_SESSION['error']="This record is successfully registered!";
  }
if(!$sqlrt)
  {
 $_SESSION['error']= $_SESSION['error']." Sorry unable to register this record into resource team!";
  }
 }
if(!$sql)
  {
$_SESSION['error']="Sorry unable to register this record!";
  }

  }
}
  }
  }
  if($T_NIC_Number==""||$SchName==""||$First_Name==""||$Last_Name==""||$Date_Of_Birth==""||$Gender==""||$Nature_Of_Appointment==""||$Academic_Qualifications==""||$Service==""||$Address==""||$Appointment_Date==""||$Appointed_Subject=="")
	{
		$_SESSION['errorin']="Indexed details are required,Please fill all!";
	}
}
   	}
			}
		}
if($_SESSION['OK']!="OK")
{
	?>
<div id="lefttablereg">
<form action="#" method="POST" name="form1">
<table width="782" border="0" class="tablefontv">
  <tr>
    <td height="21" colspan="5" scope="row" class="err">   <?php
    if(isset($_POST['Register_Tea']))
{
	if(isset($_SESSION['errorin']))
	{echo '<img src="images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['error']))
	{echo '<img src="images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
	}
	if(isset($_SESSION['errorrt']))
	{echo '<img src="images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorrt'];
		unset($_SESSION['errorrt']);
	}
	if(isset($_SESSION['errorexi']))
	{echo '<img src="images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorexi'];
		unset($_SESSION['errorexi']);
		
	}
	if(isset($_SESSION['errornotallo']))
{echo '<img src="images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errornotallo'];
unset($_SESSION['errornotallo']);
}
if(isset($_SESSION['errordeg']))
{echo '<img src="images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errordeg'];
unset($_SESSION['errordeg']);
}
}?>
</td>
    <td width="191">&nbsp;</td>
  </tr>
  <tr>
    <td width="22" scope="row">&nbsp;</td>
    <td width="18" scope="row"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td width="176" height="25" scope="row">Firstname: </td>
	<?php
	if(isset($_POST['Register_Tea'])||isset($First_Name))
{
echo '<td>';
echo "<input type='text' name='First_Name' value='$First_Name' readonly='readonly'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='First_Name' readonly='readonly'/>";
echo '</td>';

}?>
    <td width="306"></td>
    <td width="43">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td scope="row">&nbsp;</td>
    <td scope="row"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td height="25" scope="row">Lastname:</td>
	<?php
	   if(isset($_POST['Register_Tea'])||isset($Last_Name))
{
echo '<td>';
echo "<input type='text' name='Last_Name' value='$Last_Name' readonly='readonly'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Last_Name' readonly='readonly'/>";
echo '</td>';

}?>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td scope="row">&nbsp;</td>
    <td scope="row"><font color="red" size="+2">
      <p align="center">&nbsp;</p></font></td>
    <td height="25" scope="row">Role:</td><td>
	<select name="Role" id="Role">
        <?php
		 if($Role!="")
	  {
	  echo '<option value="'.$Role.'">'.$Role.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
$tea=mysql_query("SELECT DISTINCT(Role) FROM teacher");
	  
  while($row=mysql_fetch_array($tea))
  {
	 $R=$row['Role'];
if($R!=$Role)
{
	  echo '<option value="'.$R.'">'.$R.'</option>';
}
  }
	  ?>
      </select>
	  <font color="red">or </font><label>New role:</label>
	  <?php	 
 if($New_Role!="")
	  {
echo "<input type='text' name='New_Role' value='$New_Role'/>";
}
else{	  
echo "<input type='text' name='New_Role'/>";
}
	  ?>
	  </td>
	  <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td scope="row">&nbsp;</td>
    <td scope="row"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td height="25" scope="row">NIC Number: </td>
	<?php
	   if(isset($_POST['Register_Tea'])||isset($_GET['T_NIC_Number']))
{
if(isset($_GET['$T_NIC_Number']))
{
$T_NIC_Number=$_GET['$T_NIC_Number'];
}
echo '<td>';
echo "<input type='text' name='T_NIC_Number' value='$T_NIC_Number'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='T_NIC_Number'/>";
echo '</td>';

}?>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td scope="row">&nbsp;</td>
    <td scope="row"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td scope="row">Gender:</td>
    <td>
	<?php
	   if(isset($_POST['Register_Tea']))
{
	if($Gender=="Male")
	  {
	    echo '<input type="radio" name="Gender" value="Male" id="Gender_0" checked="checked" />';
	   echo "Male";
	  }
	  else
	  {
		  echo '<input type="radio" name="Gender" value="Male" id="Gender_0" />';
	   echo "Male";
	  }
        echo '<br />';
        if($Gender=="Female")
		{
          echo '<input type="radio" name="Gender" value="Female" id="Gender_1" checked="checked" />';
          echo "Female";
  }
  else
  {
	   echo '<input type="radio" name="Gender" value="Female" id="Gender_1" />';
          echo "Female";
  }
  }
  else
  {
  ?>
      <label>
        <input type="radio" name="Gender" value="Male" />
        Male</label>
      <br />
      <label>
        <input type="radio" name="Gender" value="Female" />
        Female</label>
      <?php
		}
		?>
    </td>
  </tr>
  <tr>
    <td scope="row">&nbsp;</td>
    <td scope="row"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td height="25" scope="row">Date of birth: </td>
	<?php
	   if(isset($_POST['Register_Tea']))
{
echo '<td>';
echo "<input type='text' name='Date_Of_Birth' value='$Date_Of_Birth' class='inputDate' id='inputDate'>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Date_Of_Birth' value='$t_d' class='inputDate' id='inputDate'>";
echo '</td>';

}?>
    <td></td>
  
  </tr>
  <tr>
    <td scope="row">&nbsp;</td>
    <td scope="row"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td height="29" scope="row">School's Name:</td>
	
    <td>
    <?php
	    echo "<input type='text' id='SchName' name='SchName' onKeyUp='showSch(this.value)' value='$SchName' onClick='cleartbox()' size='40'/>";
	  ?>
	 </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

<table width="962" height="61" border="0" class="tablefontv">
  <tr>
    <td width="43" scope="row">&nbsp;</td>
    <td width="10" scope="row"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td width="291" height="21" scope="row">Contact address: </td>

    <td colspan="3">	<?php
	   if(isset($_POST['Register_Tea']))
{

echo "<input type='text' name='Address' value='$Address'/>";


}
else
{

echo "<input type='text' name='Address'/>";


}?></td>
	
  </tr>
  <tr>
    <td scope="row">&nbsp;</td>
    <td scope="row">&nbsp;</td>
    <td height="21" scope="row">Telephone number: </td>
	
    <td width="168"><label>Home:
	<?php
	   if(isset($_POST['Register_Tea']))
{
echo '<td>';
echo "<input type='text' name='Home_Tp_Number' value='$Home_Tp_Number'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Home_Tp_Number'/>";
echo '</td>';

}?>
  
    </label></td>
    <td width="185"><label>Work:
	<?php
	   if(isset($_POST['Register_Tea']))
{
echo '<td>';
echo "<input type='text' name='Office_Tp_Number' value='$Office_Tp_Number'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Office_Tp_Number'/>";
echo '</td>';

}?>
    
    </label></td>
    <td width="242"><label>Cellular:
	<?php
	   if(isset($_POST['Register_Tea']))
{
echo '<td>';
echo "<input type='text' name='Mobile_Tp_Number' value='$Mobile_Tp_Number'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Mobile_Tp_Number'/>";
echo '</td>';

}?>
    
    </label></td>
  </tr>
 </table>

<table width="1025" border="0" class="tablefontv">
  <tr>
    <td>&nbsp;</td>
    <td><font color="red" size="+2"><p align="center">*</p></font></td>
    <td height="38">Nature of the appointment:</td>
    <td width="155"><?php
	   if(isset($_POST['Register_Tea']))
{

echo "<input type='text' name='Nature_Of_Appointment' value='$Nature_Of_Appointment'/>";


}
else
{

echo "<input type='text' name='Nature_Of_Appointment'/>";


}?></td>
  </tr>
  <tr>
    <td width="18">&nbsp;</td>
    <td width="11"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td width="192" height="26">Appointment Date:</td>
	<?php
	   if(isset($_POST['Register_Tea']))
{
echo '<td>';
echo "<input type='text' name='Appointment_Date' value='$Appointment_Date' class='inputDate1' id='inputDate1'>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Appointment_Date' value='$t_d' class='inputDate1' id='inputDate1'>";
echo '</td>';

}?>
	<td width="147"></td>
    
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><font color="red" size="+2"><p align="center">*</p></font></td>
    <td height="27">Appointed Subject:</td>
    <?php
	   if(isset($_POST['Register_Tea']))
{
echo '<td>';
echo "<input type='text' name='Appointed_Subject' value='$Appointed_Subject'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Appointed_Subject'/>";
echo '</td>';

}?>
    <td colspan="5">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td height="35">Achievements &amp; Awardes:</td>


    <td colspan="5"><textarea name="Achievements_Awards" cols="40" rows="3">
	<?php  if(isset($_POST['Register_Tea']))
{
echo $Achieve; 
}?></textarea></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>Resource team member:</td>
    <td>
	<?php
	   if(isset($_POST['Register_Tea']))
{
	if($Res_Team=="Yes")
	  {
		echo '<input type="radio" name="Res_Team" value="Yes" id="Res_Team_0" checked="checked"/>';
	   echo "Yes";
	  }
	  else
	  {
		  echo '<input type="radio" name="Res_Team" value="Yes" id="Res_Team_0"/>';
	   echo "Yes";
	  }
        echo '<br />';
        if($Res_Team=="No")
		{ 
		
          echo '<input type="radio" name="Res_Team" value="No" id="Res_Team_1" checked="checked"/>';
          echo "No";
  }
  else
  {
	   echo '<input type="radio" name="Res_Team" value="No" id="Res_Team_1"/>';
          echo "No";
  }
  }
  else
  {
  ?>
	<label>
	     <input type="radio" name="Res_Team" value="Yes" onClick="re_te()"/>
      Yes</label>
      <br />
      <label>
       <input type="radio" name="Res_Team" value="No" onClick="hide()"/>
        No</label>
		<?php
		}
		?></td>
         <?php
		$Res_Team=$_POST['Res_Team'];
		if($Res_Team=="Yes")
		{
   echo '<td width="162">';
	echo 'Training Id:';
	echo '</td>';
	echo '<td>';
	?>
	<select name="Training_Name" id="Training_Name">
        <?php
		 if(isset($Training_Name))
	  {
	  echo '<option value="'.$Training_Name.'">'.$Training_Name.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
$tra=mysql_query("SELECT DISTINCT(Training_Name) FROM training");
	  
  while($row=mysql_fetch_array($tra))
  {
	 $Tra_Name=$row['Training_Name'];
if($Tra_Name!=$Training_Name)
{
	  echo '<option value="'.$Tra_Name.'">'.$Tra_Name.'</option>';
}
  }
	  ?>
      </select>
	  <?php
echo '</td>';		
	echo '<td width="130">';
    echo 'From Date:';
	echo '</td>';
	echo '<td>';
	if(isset($_POST['Register_Tea']))
{
echo "<input type='text' name='From_Date' value='$From_Date' class='inputDate2' id='inputDate2'/>";
}
else
{
echo "<input type='text' name='From_Date' class='inputDate2' value='$t_d' id='inputDate2'/>";
}
	
	echo '</td>';

  	}
		?>
    <td width="282"><div id="tioptions">	
  	</div></td>
       </tr>
  <tr>
    <td>&nbsp;</td>
    <td><font color="red" size="+2"><p align="center">*</p></font></td>
    <td height="24">Service:</td>
	<?php
	 if(isset($_POST['Register_Tea']))
{
echo '<td>';
echo "<input type='text' name='Service' value='$Service'/>";
echo '</td>';

}
else
{
echo '<td>';
echo "<input type='text' name='Service'/>";
echo '</td>';

}?>
    <td colspan="5"></td>
	
  </tr>
</table>
<table width="1057" border="0" class="tablefontv">
  <tr>
    <td width="12">&nbsp;</td>
    <td width="10"><font color="red" size="+2"><p align="center">*</p></font></td>
    <td width="405" height="53"><h3>Academic qualifications:</h3>
      <?php
if(isset($_POST['Register_Tea']))
{
if($A_Qua!="")
{
	 $acQua= explode(",",$A_Qua);
	 $ol="";
	 $al="";
	 $oac="";
	
for($i=0;$i<count($acQua);$i++)
{
if($acQua[$i]=='O/Level')
{
$ol="yes";
echo "<input type='checkbox' name='Academic_Qualifications[]' value='O/Level' checked='checked'/>";
  echo "O/Level";
   echo '<br/>';
  }   
  if($acQua[$i]=='A/Level')
  {$al="yes";
  echo "<input type='checkbox' name='Academic_Qualifications[]' value='A/Level' checked='checked'/>";
 echo "A/Level";
  echo '<br/>';
 }
 if($acQua[$i]!='O/Level'&&$acQua[$i]!='A/Level'&&$acQua[$i]!="")
  {
  $oac="yes";
    $ac=substr($acQua[$i],4);
	echo "<input type='checkbox' name='Academic_Qualifications[]' value='Degree_holder' checked='checked'/>";
echo "Degree holder,Subjects:";
echo '<br/>';
?>
      <textarea name='Academic_Qualifications_Deg' cols='40' rows='3'><?php echo $ac." "; ?></textarea>
      <?php
 echo '<br/>';
}
}
if($ol=="")
{
echo "<input type='checkbox' name='Academic_Qualifications[]' value='O/Level'/>";
  echo "O/Level";
  echo '<br/>';
}
if($al=="")
{
echo "<input type='checkbox' name='Academic_Qualifications[]' value='A/Level'/>";
 echo "A/Level";
   echo '<br/>';
}
if($oac=="")
{
echo "<input type='checkbox' name='Academic_Qualifications[]' value='Degree_holder'/>";
echo "Degree holder,Subjects:";
  echo '<br/>';
echo "<textarea name='Academic_Qualifications_Deg' cols='40' rows='3'></textarea>";
}
}
else
{
echo "<input type='checkbox' name='Academic_Qualifications[]' value='O/Level'/>";
  echo "O/Level";
  echo '<br/>';
echo "<input type='checkbox' name='Academic_Qualifications[]' value='A/Level'/>";
 echo "A/Level";
   echo '<br/>';
echo "<input type='checkbox' name='Academic_Qualifications[]' value='Degree_holder'/>";
echo "Degree holder,Subjects:";
  echo '<br/>';
echo "<textarea name='Academic_Qualifications_Deg' cols='40' rows='3'></textarea>";
}
}
else
{
echo "<input type='checkbox' name='Academic_Qualifications[]' value='O/Level' />";
  echo "O/Level";
 echo "<input type='checkbox' name='Academic_Qualifications[]' value='A/Level'/>";
 echo "A/Level";
echo "<input type='checkbox' name='Academic_Qualifications[]' value='Degree_holder'/>";
echo "Degree holder,Subjects:";
echo "<textarea name='Academic_Qualifications_Deg' cols='40' rows='3'></textarea>";
}
?></td>
    <td align="middle">
	<label>Specialised in:</label></td>
    <td width="500">
	<?php
$Spec_In=mysql_query("SELECT DISTINCT(Specialised_In) FROM teacher");	  
  while($row=mysql_fetch_array($Spec_In))
  {
$Spe_In=$row['Specialised_In'];
$splited_spe_In=explode(",",$Spe_In);
$All_Specia_In=explode(",",$Specia_In);
for($sp=0;$sp<count($splited_spe_In);$sp++)
{
$s_exists="";
for($spa=0;$spa<count($All_Specia_In);$spa++)
{
if($splited_spe_In[$sp]==$All_Specia_In[$spa])
{
$s_exists="yes";
break;
}
}
if($s_exists=="")
{
if(empty($Specia_In))
{
 $Specia_In=$splited_spe_In[$sp];
}
else
{
 $Specia_In=$Specia_In.",".$splited_spe_In[$sp];
}
}
}
}
	$allSpecia_In=explode(",",$Specia_In);
	$regSpecia_In=explode(",",$reg_Specia_In);
	if(isset($_POST['Register_Tea']))
	  {
for($s=0;$s<count($allSpecia_In);$s++)
{ 
$Spe_exists="";  
for($i=0;$i<count($regSpecia_In);$i++)
{		  
if($allSpecia_In[$s]==$regSpecia_In[$i])
{
$Spe_exists="yes";
  echo "<input type='checkbox' name='Specialised_In[]' value='$allSpecia_In[$s]' checked='checked'/>";
  echo $allSpecia_In[$s].'</br>';
  }
  }
  if($Spe_exists=="")
  {
  echo "<input type='checkbox' name='Specialised_In[]' value='$allSpecia_In[$s]'/>";
  echo $allSpecia_In[$s].'</br>';
  }
  }
  echo "<font color='red'>or</font> New";
  echo "<input type='text' name='New_Specialised_In' value='$New_Specialised_In'";
	  }
	  else
	  {
for($s=0;$s<count($allSpecia_In);$s++)
{	  
  echo "<input type='checkbox' name='Specialised_In[]' value='$allSpecia_In[$s]'/>";
  echo $allSpecia_In[$s].'</br>';
  }
  echo "<font color='red'>or</font> New";
  echo "<input type='text' name='New_Specialised_In'";
	  }
  ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td height="71"><br/>
      <h3>Profitional qualifications: </h3>
      <textarea name="Professional_Qualifications" cols="40" rows="3">
	  <?php  if(isset($_POST['Register_Tea']))
{
echo $Profe_Qualifications; 
}?>
      </textarea>
     </td>
    <td><a href="?action=reg_tea" class="reset">Reset |</a>
      <input name="Register_Tea" type="submit" value="Register" class="buttonok"/>
     </td>
    <td>&nbsp;</td>
  </tr>
</table>
<br/>
<br/>
<br/>
 </form>
 </div>
 <div id="righttablereg">
<?php
 if($_SESSION['OK']!="OK")
{
?>
 <div class="suggestionListsch" id="List"></div>
<?php
}
?>
</div>
<?php
}
}
else
{
unset($_SESSION['OK']);
?>
	  <font class="err">
<?php
if(isset($_SESSION['Photo_Delete']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['Photo_Delete'];
		unset($_SESSION['Photo_Delete']);
	}
if(isset($_SESSION['errornews']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errornews'];
		unset($_SESSION['errornews']);
	}
	if(isset($_SESSION['errorimgexi']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorimgexi'];
		unset($_SESSION['errorimgexi']);
	}
	if(isset($_SESSION['add_news']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['add_news'];
		unset($_SESSION['add_news']);
	}
if(isset($_SESSION['error']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['error'];
		if($_SESSION['error']=="Successfully restored!")
		{
			$email="Yes";
		}
		unset($_SESSION['error']);
	}?>
	</font>
    <font class="succ">
    <?php
	if(isset($_SESSION['errorimgsucc']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorimgsucc'];
		unset($_SESSION['errorimgsucc']);
	}
	?>
    </font>
    <div id="lefttable_index">
 <br/>
 <?php
 if($_GET['action']=="forget_pw"&&$_SESSION['successfp']!="succ")
{
?>
<form action="#" method="POST"><table width="626" height="84" border="0" class="tablefontv">
    <tr>
      <td height="19" colspan="5"  scope="row"  class="err">
	  <?php
	  if(isset($_SESSION['error']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
		
	}
	?>
      </td>
     
    </tr>
       <tr>
         <th width="21"row" bgcolor="#06AEFF">&nbsp;</th>
      <th width="109" height="33"row" bgcolor="#06AEFF">Username: </th>
      <td width="168" bgcolor="#06AEFF"><input type="text" name="Username" id="Username"/></td>
      <td width="310" bgcolor="#06AEFF">
	 	  <input name="Find" align="middle" type="button" class="buttonok" value="Find" onClick="findpw(Username.value)"/>
	    </td>
          </tr>
    <tr>
      <th height="18" colspan="4" bgcolor="#4AC5FF" scope="row"><div id="password"></div>
            </th>
      </tr>
   
  </table>
  </form>
<?php
}
 if((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']=="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']=="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']=="succ"))||loggedin())
{
if(($_GET['action']=="create"&&$_SESSION['successcre']!="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']!="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']!="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']!="succ"))
 {
 }
 else
 {
 ?>
<form action="#" method="post" enctype="multipart/form-data" name='dele_photo'>
<table border="0" cellpadding="1" align="left" >
<tr>
  <td>
</td>
<?php
$Access_Type=$_SESSION['Access_Type'];
$NIC_Number=$_SESSION['NIC_Number'];
$name="Delete photo by_".$Access_Type."_".$NIC_Number;
?>
  <td><input type="button" id="del_photo" value="Delete photo" name="<?php echo $name;?>" onClick="get_del_popup(this.name)"/><input type="hidden" id="del_Image_name" name="del_Image_name"/>
    <div id="pop_up"></div></td>
  <td>&nbsp;</td>
</tr>
<tr bgcolor = "lightgreen">
<td>
<font color="#11A6D4"><b>Upload Photo</b></font></td>
<td><input name="image" type="file"></td>
<td><input type="submit" value="OK" name="UploadPhoto"/></td>
<td></td></tr></table>
<table class="righttable_filter" align="right">
<tr><td></td>
<td><b><font color="blue">Quick Filter<font></b></td>
<td><?php
  $user=$_SESSION['Access_Type'];
if($user=="Teacher in Charge")
{
$NIC_Number=$_SESSION['NIC_Number'];
$user_detail=$user.",".$NIC_Number;
}
else
{
$user_detail=$user.",_";
}
?>
  <form action=""> 
    <select name="attribute" onChange="showData(this.value,this.id)" id="<?php echo $user_detail;?>">
      <option value="Select One">Select One</option>
      <option value="Resource Persons">Resource Persons</option>
      <option value="ICT Teachers">ICT Teachers</option>
      <option value="Graduate Teachers">Graduate Teachers</option>
      <option value="Schools with Labs">Schools with Labs</option>
      <option value="Schools without Labs">ICT subject functioning schools without Labs</option> 
      </select>
  </form></td>
<td></td></tr>
</table>
</form>
<?php
}
}
?>
<table>
<tr>
<td>    
<?php
if($_POST['Delete_Post'])
{
$qucol="SHOW COLUMNS FROM posts";
$resultcol=mysql_query($qucol);
$totcol=mysql_num_rows($resultcol);
while($rowcolu=mysql_fetch_row($resultcol))
{
if($rowcolu[0]!="Last_Updated_Date")
{
if(empty($colnamearray))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
}
}
if($_SESSION['Access_Type']=="Administrator")
{
$result=mysql_query("SELECT * FROM posts");
}
else if($_SESSION['Access_Type']=="Teacher in Charge")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
  $Own_School_Id=$rowsch['School_Id'];
$resultall=mysql_query("SELECT * FROM posts");
while($rowall=mysql_fetch_array($resultall))
  {
  $nic=$rowall['Posted_By'];
  $get_Scho=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$nic'");
   if($rowscho=mysql_fetch_array($get_Scho))
{
   $School_Id=$rowscho['School_Id'];
   if($School_Id==$Own_School_Id)
   {
   if(empty($nic_no))
   {
   $nic_no='"'.$nic.'"';
   }
   else
   {
   $nic_no=$nic_no.',"'.$nic.'"';
   }
}
}
  }
    if($nic_no!="")
  {
  $result=mysql_query("SELECT * FROM posts WHERE Posted_By in($nic_no)");
  }
  if($nic_no=="")
  {
  $_SESSION['postdel']="Sorry you are not allowed to do this!";
   }
}
else
{
$_SESSION['postdel']="Sorry you are not allowed to do this!";
}
}
else if($_SESSION['Access_Type']=="Teacher")
{
 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   $result=mysql_query("SELECT * FROM posts WHERE Posted_By='$NIC_Number'");
}
else
{
$_SESSION['postdel']="Sorry you are not allowed to do this!";
}
}
if($result)
{
if(mysql_num_rows($result)>0)
{
$rnum=0;
echo "<form action='#' method='post'>";
echo "<input type='hidden' size='1' id='Verifi' name='Verifi'/>";
echo '<table width="937" border="1" class="tablefontv">';
echo '<tr bgcolor="#6AB5FF">';
?>
<td width="39"></td>
<?php
$cnamearray=explode(',',$colnamearray);
     for($cv=0;$cv<count($cnamearray);$cv++)
	{
	 $val=$cnamearray[$cv];
	$th_cname= str_replace("_"," ",$val);
		
	$valu=$row[$val];
  echo '<td>';
		echo $th_cname;
		echo '</td>';
   
	}
	echo '</tr>';
  while($row=mysql_fetch_array($result))
  {
$rnum=$rnum+1;
$p=$row['Post_Id'];
$delVerification="delVerification".$rnum;
$name=$p;
?>
<tr bgcolor="#999999">

<td width="39"><?php echo "<input type='submit' id='$name' name='dele' onclick='DeleteVerification($rnum,this.id)' class='submitdelete' value=''/>";?></form></td>
<?php 
	$cnamearray=explode(',',$colnamearray);
	for($cv=0;$cv<count($cnamearray);$cv++)
	{
	$val=$cnamearray[$cv];
	$th_cname= str_replace("_"," ",$val);
	$valu=$row[$val];
	echo '<td>';
		echo $valu;
		echo '</td>';
    	
    }
  echo '</tr>';
  }   
echo "</table><br/><a href='index.php'><img src='images/back.jpg'/></a>";
}
}
}
if((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']=="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']=="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']=="succ"))||!isset($_GET['action'])||($_GET['action']!="create"&&$_GET['action']!="forget_pw"&&$_GET['action']!="pri_setting"&&$_GET['action']!="acc_setting"))
{
	if(!$_POST['Delete_Post'])
	{
	?>
		<?php
	////////////
	if(loggedin())
	{
	?>
 </br><div id="righttable_search"><table><tr>
    <td width="243" height="22">&nbsp;</td>
    <td width="244" align="center"><?php
$oper=$_POST['Adv_Search_operator'];
$textadv=$_POST['texthintadv'];

 if($oper!="")
 {
if($textadv==""||$textadv=="Search Keywords")
{
	$_SESSION['adv_empty']="Please enter the keyword to search!";
}
 }
	?>
      <font class="err">
      <?php
    if(isset($_SESSION['adv_empty']))
 {echo '<img src="images/alert.jpg" width="12" height="12"/>';
	 echo $_SESSION['adv_empty'];
	 unset($_SESSION['adv_empty']);
 }
   ?>
      </font></td>
       </tr>
 </table>
 <div id="righttablesearleft"><table width="200" border="0" class="righttable">
 <tr><td><h3 align="center">Search</h3></td>
   </tr>
  <tr>
  <td>
     <form name="form1">
<input type="text" name="texthint" id="texthint" class="field" onKeyUp="showHint(this.value)" value="Search Keywords" size="20" onClick="cleartbox(this.name)"/>
<input type="button" class="image" value="" onClick="getRes(texthint.value)">
</form><br/>
<br/>
<div class="suggestionList" id="List"></div>
  </td>
  </tr>
  </table></div><div id="righttablesearleft">
  <table width="297" border="0" class="righttable">
  <tr>
  <tr><td width="182"><h3 align="center">Advanced Search</h3></td>
     </tr>
  <tr>
  <td colspan="2">
   <form action="" name="form2" method="post">
<?php
if($textadv!="")
{
echo "<input type='text' class='field1' name='texthintadv' id='texthintadv' onKeyUp='showHintadv(this.value)' value='$textadv' size='20' onClick='cleartbox(this.name)'/>";
}
else
{
?>
<input type="text" class="field1" name="texthintadv" id="texthintadv" onKeyUp="showHintadv(this.value)" value="Search Keywords" size="20" onClick="cleartbox(this.name)"/>
<?php
}
$user=$_SESSION['Access_Type'];
if($user=="Teacher in Charge")
{
$NIC_Number=$_SESSION['NIC_Number'];
$user_detail=$user.",".$NIC_Number;
}
else
{
$user_detail=$user.",_";
}
?>
<input type="button" class="imageadvsearch" value="" onClick="getResadv(texthintadv.value,this.id)" id="<?php echo $user_detail;?>"><div id="operator">
<select name="Adv_Search_operator" id="Adv_Search_operator" onChange="javascript:this.form.submit()">
 <?php
	if($oper!="")
	{
		 echo '<option value="'.$oper.'">'.$oper.'</option>';
		 if($oper!="More Than")
		 {
			 ?>
<option value="More Than">More Than</option>

<?php
		 }
		 if($oper!=">=")
		 {
			 ?>
		 <option value=">=">>=</option>

<?php
		 }
		 if($oper!="Less Than")
		 {
			 ?>
			 <option value="Less Than">Less Than</option>
			 
<?php
		 }
		 if($oper!="<=")
		 {
			 ?>
<option value="<="><=</option>
<?php
		 }
		 if($oper!="Equal To")
		 {
			 ?>
<option value="Equal To">Equal To</option>
<?php
		 }
}
	else
	{
	?>
<option value="Select One">Select One</option>
<option value="More Than">More Than</option>
<option value=">=">>=</option>
<option value="Less Than">Less Than</option>
<option value="<="><=</option>
<option value="Equal To">Equal To</option>
<?php
	}
?>
</select></div>
<div class="val" id="val">
<?php
if($textadv!="")
{
	?>
    <br/>
Value:<input type="text" name="value" id="value"/>
<?php
}
	?>
</div>
</form>
 <br/>
  <br/>
<div class="suggestionListadv" id="Listadv"></div>
  </td>
  </tr>
  </table></div></div>
  <div id="searchres_adv">
  <?php
  $tab="";
  $col="";
  $val="";
  if($_GET['t']!=""&&$_GET['c']!=""&&$_GET['v']!=""&&($textadv=="Search Keywords"||$textadv==""))
  {
  $tab=$_GET['t'];
  $col=$_GET['c'];
  $val=$_GET['v'];
$param=$tab.",".$col.",".$val;
$quet="SHOW COLUMNS FROM $tab";
$resultcolt=mysql_query($quet);
if(substr($tab,0,3)=="del")
{
$qu="SELECT * FROM $tab WHERE ".$col." LIKE '%$val%'";
}
else
{
$qu="SELECT * FROM $tab WHERE ".$col."='$val'";
}
$nc=mysql_num_rows($resultcolt);
	  $seaquery=mysql_query($qu);
	  $Exc_que=$qu;
	  if(mysql_num_rows($seaquery)!=0)
	  {
	  if($nc>5)
	  {
	  echo '<div style="width:568px; overflow-x:scroll;">';
	  }
	  echo '<br/>';
	  echo '<br/>';
	  echo '<br/>';
	 		  echo '<table border="1" class="tablefontv" align="left">';
		     echo '<tr bgcolor="#6AB5FF">';
		  while($rowsea=mysql_fetch_row($resultcolt))
		  {
			echo '<td>'.$rowsea[0].'</td>';
		  }
		    echo '</tr>';
			 echo '<tr>';
		 while($rowqu=mysql_fetch_array($seaquery))
		  {
		  for($i=0;$i<$nc;$i++)
		  {
		  echo '<td bgcolor="#999999">'.$rowqu[$i].'</td>';
			  }
			   echo '</tr>';
			   }
			  
			   echo '</table>';
			   if($nc>5)
	  {
	  echo '</div>';
	  }
	  ?>
	  <br/>
    	 <?php
		 //echo '<a href="Printpage.php?p='.$param.'"><input type="button" name="print" class="print" value=""/></a>';
if($seaquery)
{
$Exc_quer=str_replace("'","@",$Exc_que);
echo "<form action='exportreport.php' method='post'><input type='submit' name='ToExcel' class='print' value=''/><input type='hidden' value='$Exc_quer' name='query'/><input type='hidden' value='$tab' name='Exc_table_name'/></form>";
}
	  }
  }
  ?>
  </div>
	<?php
	}
	?>
	</div>
<?php
	}
	}
	?>
    </td>
    <td>
    </td>
    </tr>
    </table>   
		<font class="err">
	<?php
if(isset($_SESSION['postdel']))
{
?>
<br/>
<br/>
	<?php
echo '<img src="images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['postdel'];
unset($_SESSION['postdel']);
}
?>
</font>
<?php
if(!$_POST['Delete_Post'])
{
if($_GET['action']=="pri_setting"&&$_SESSION['successpri']!="succ")
{
?>
<form action="#" method="POST"><table width="1103" height="154" border="0" class="tablefontv">
    <tr>
      <td height="19" colspan="5"  scope="row">
	  <font  class="err">
      <?php
	  if(isset($_SESSION['errornews']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errornews'];
		unset($_SESSION['errornews']);
	}
		if(isset($_POST['Register']))
{
	if(isset($_SESSION['error']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
		
	}
	 	if(isset($_SESSION['errorop']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorop'];
		unset($_SESSION['errorop']);
		
	}
}
		?>
		</font>
		</td>
      <td width="7" rowspan="12">&nbsp;</td>
    </tr>
       <tr>
         <th width="28"row" bgcolor="#06AEFF">&nbsp;</th>
      <th width="164" height="33"row" bgcolor="#06AEFF">Old Password: </th>
      <td colspan="2" bgcolor="#06AEFF"><input type="password" name="OldPassword" onClick="get_clear()"/></td>
      <td width="530">&nbsp;</td>
      </tr>
       <tr>
         <th scope="row" bgcolor="#4AC5FF">&nbsp;</th>
         <th height="34" scope="row" bgcolor="#4AC5FF">New Password: </th>
         <td width="130" bgcolor="#4AC5FF"><?php
	  if(isset($npwre))
	  {
      echo "<input type='password' name='NewPassword' value='$npwre' onKeyUp='showProgress(this.value)'/>";
	  }
	  else
	  {
		  echo '<input type="password" name="NewPassword" onKeyUp="showProgress(this.value)"/>';
	  }
	  ?>
         </td>
         <td width="207" bgcolor="#4AC5FF"><div id=progress>
     </div></td>
         <td></td>
       </tr>
       <tr>
         <th scope="row" bgcolor="#06AEFF">&nbsp;</th>
      <th height="34" scope="row" bgcolor="#06AEFF">Verify your new Password: </th>
      <td colspan="2" bgcolor="#06AEFF"><input type="password" name="PasswordVar" /></td>
      <td class="err"><div id="pw_err"> 
        <?php
	  if(isset($_POST['Register']))
{
   	if(isset($_SESSION['errorveri']))
	{echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorveri'];
		unset($_SESSION['errorveri']);
		
	}
}
	?></div></td>
     
	<td width="7"></td>
    </tr>

    <tr>
      <th scope="row" bgcolor="#4AC5FF">&nbsp;</th>
      <th height="21" scope="row" bgcolor="#4AC5FF">&nbsp;</th>
      <td colspan="2" bgcolor="#4AC5FF"><br/>
        <a href="?action=pri_setting" class="reset">Reset |</a>
		  <input name="Register" align="middle" type="submit" class="buttonok" value="Change" />
		      
      </td>
      <td>&nbsp;</td>
      </tr>
   
  </table></form>
<?php
}
else if($_GET['action']=="acc_setting"&&$_SESSION['successacc']!="succ")
{
?>
 <form action="#" method="POST"><table width="900" height="231" border="0" class="tablefontv">
    <tr>
      <td height="18" colspan="3"  scope="row">
	  
        <font class="err">
        <?php
		if(isset($_SESSION['errornews']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errornews'];
		unset($_SESSION['errornews']);
	}
		if(isset($_POST['Register']))
{
	if(isset($_SESSION['error']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
		
	}
	?>
    </font>
   <?php
}
		?></td>
      <td width="217" rowspan="11">&nbsp;</td>
    </tr>
    <tr>
      <th width="187" height="30"  scope="row" bgcolor="#06AEFF">       
        First Name:</th>
      <td width="180" bgcolor="#06AEFF">
      <?php
	  $Username=$_SESSION['username'];
	  $getuser=mysql_query("SELECT * FROM user WHERE Login_Username='$Username'");
	  if($rowuser=mysql_fetch_array($getuser))
	  {
	  $Fir_N=$rowuser['First_Name'];
	  $Las_N=$rowuser['Last_Name'];
	  $NIC_Nu=$rowuser['NIC_Number'];
	  $Ac_Type=$rowuser['Access_Type'];
	  $E_mail=$rowuser['E_Mail'];
	  }
	  
	  if(!isset($_POST['Register']))
	  {
	    if(isset($Fir_N))
	  
{
     echo "<input type='text' name='First_Name' value='$Fir_N' />";
}
}
	  if(isset($_POST['Register']))
	  {
	   $F_N=$First_Name;
	   if(isset($F_N))
	  
{
     echo "<input type='text' name='First_Name' value='$F_N' />";
}
else
{
	echo "<input type='text' name='First_Name'/>";
}
	  }
      ?>
      </td>
      <td width="292">&nbsp;</td>
      </tr>
    <tr>
      <th height="24" scope="row" bgcolor="#4AC5FF">Last Name:</th>
      <td bgcolor="#4AC5FF">
      <?php
	  if(!isset($_POST['Register']))
	  {
	  if(isset($Las_N))
	  
{
      echo "<input type='text' name='Last_Name' value='$Las_N' />";
}
}
	  
	   if(isset($_POST['Register']))
	  {
	 $L_N=$Last_Name;
	  if(isset($L_N))
	  
{
      echo "<input type='text' name='Last_Name' value='$L_N' />";
}
else
	  
{
      echo "<input type='text' name='Last_Name' />";
}
	  }
	?></td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <th height="31" scope="row" bgcolor="#06AEFF">NIC Number :</th>
      <td bgcolor="#06AEFF">
       <?php
	    if(!isset($_POST['Register']))
	  {
	   if(isset($NIC_Nu))
	  
{
      echo "<input type='text' name='NIC_Number' value='$NIC_Nu' />";
}
}
	   if(isset($_POST['Register']))
	  {
	 $NIC=$NIC_Number;
	  if(isset($NIC))
	  
{
      echo "<input type='text' name='NIC_Number' value='$NIC' />";
}
else
	  
{
      echo "<input type='text' name='NIC_Number' />";
}
	  }
	?></td>
      <td>&nbsp;</td>
      </tr>
	   <tr>
      <th height="31" scope="row" bgcolor="#4AC5FF">Access Type:</th>
      <td bgcolor="#4AC5FF">
	  <select name="Access_Type" id="select">
       <?php
	   	  if(!isset($_POST['Register']))
	  {
	   echo '<option value="'.$Ac_Type.'">'.$Ac_Type.'</option>';
	   if($Ac_Type=="Teacher")
		  {
			  echo '<option value="Teacher in Charge">Teacher in Charge</option>';
			  }
	     if($Ac_Type=="Administrator")
		  {
		  echo '<option value="Zonal Admin">Zonal Admin</option>';
		  echo '<option value="Teacher in Charge">Teacher in Charge</option>';
		  echo '<option value="Teacher">Teacher</option>';
		   }
		   if($Ac_Type=="Teacher in Charge")
		  {
	echo '<option value="Teacher">Teacher</option>';
			}
		}
	  if(isset($_POST['Register']))
	  {
		   if($Access_Type=="")
		  {
		 echo '<option value="Teacher in Charge">Teacher in Charge</option>';
	     echo '<option value="Teacher">Teacher</option>';
		  }
		   if($Access_Type=="Teacher in Charge")
		  {
		  echo '<option value="'.$Access_Type.'">'.$Access_Type.'</option>';
	echo '<option value="Teacher">Teacher</option>';
			}
		  if($Access_Type=="Teacher")
		  {
		  echo '<option value="'.$Access_Type.'">'.$Access_Type.'</option>';
	 echo '<option value="Teacher in Charge">Teacher in Charge</option>';
			}
	    if($Access_Type=="Administrator")
		{
		echo '<option value="'.$Access_Type.'">'.$Access_Type.'</option>';
		  echo '<option value="Zonal Admin">Zonal Admin</option>';
			 echo '<option value="Teacher in Charge">Teacher in Charge</option>';
			echo '<option value="Teacher">Teacher</option>';
		}
	  }
	 ?>
</select>
	  </td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <th height="29" scope="row" bgcolor="#06AEFF">E-Mail: </th>
      <td bgcolor="#06AEFF">   <?php
	  if(!isset($_POST['Register']))
	  {
	  if(isset($E_mail))
	  
{
      echo "<input type='text' name='E_Mail' value='$E_mail' />";
}
}
	  
	   if(isset($_POST['Register']))
	  {
	 $E_M=$E_Mail;
	  if(isset($E_M))
	  
{
      echo "<input type='text' name='E_Mail' value='$E_M' />";
}
else
	  
{
      echo "<input type='text' name='E_Mail' />";
}
	  }
	 ?></td>
      <td>&nbsp;</td>
      </tr>
    

    <tr>
      <th height="24" scope="row" bgcolor="#4AC5FF">&nbsp;</th>
      <td bgcolor="#4AC5FF"><a href="?action=acc_setting" class="reset">Reset |</a>
        <input name="Register" align="middle" type="submit" value="Set" class="buttonok"/>
		      
      </td>
      <td>&nbsp;</td>
      </tr>
   
  </table></form>
<?php
}
else if($_GET['action']=="create"&&$_SESSION['successcre']!="succ")
{

?>
<form action="#" method="POST"><table width="900" height="364" border="0" class="tablefontv">
    <tr>
      <td height="18" colspan="5"  scope="row">
	  <font  class="err">
	  <?php
	  if(isset($_SESSION['errornews']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errornews'];
		unset($_SESSION['errornews']);
	}
		if(isset($_POST['Register']))
{
	if(isset($_SESSION['errorin']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['error']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
		
	}
	if(isset($_SESSION['errorat']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorat'];
		unset($_SESSION['errorat']);
		
	}
		if(isset($_SESSION['errorusna']))
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorusna'];
		unset($_SESSION['errorusna']);
		
	}
	if(isset($_SESSION['errors'])&&$_SESSION['errors']!="")
	{
	echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errors'];
		unset($_SESSION['errors']);
	}
}
		?>
        </font>
      </td>
      <td width="5" rowspan="12">&nbsp;</td>
    </tr>
    <tr>
      <th width="27" height="23"  scope="row" bgcolor="#06AEFF">&nbsp;</th>
      <th width="166"  scope="row" bgcolor="#06AEFF">First Name:</th>
      <td colspan="2" bgcolor="#06AEFF">
      <?php
	  if(isset($_POST['Register']))
	  {
	   $F_N=$First_Name;
	   if(isset($F_N))
	  
{
     echo "<input type='text' name='First_Name' value='$F_N' />";
}
else
{
	echo "<input type='text' name='First_Name'/>";
}
	  }
	  else
{
	echo "<input type='text' name='First_Name'/>";
}
      ?>
      </td>
      <td width="356">&nbsp;</td>
      </tr>
    <tr>
      <th height="23" bgcolor="#4AC5FF" scope="row">&nbsp;</th>
      <th height="23" bgcolor="#4AC5FF" scope="row">Last Name:</th>
      <td colspan="2" bgcolor="#4AC5FF">
        <?php
	   if(isset($_POST['Register']))
	  {
	 $L_N=$Last_Name;
	  if(isset($L_N))
	  
{
      echo "<input type='text' name='Last_Name' value='$L_N' />";
}
else
	  
{
      echo "<input type='text' name='Last_Name' />";
}
	  }
	  else
	  
{
      echo "<input type='text' name='Last_Name' />";
}
	  ?></td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <th height="23" bgcolor="#06AEFF" scope="row">&nbsp;</th>
      <th height="23" bgcolor="#06AEFF" scope="row">NIC Number :</th>
      <td colspan="2" bgcolor="#06AEFF">
        <?php
	   if(isset($_POST['Register']))
	  {
	 $NIC=$NIC_Number;
	  if(isset($NIC))
	  
{
      echo "<input type='text' name='NIC_Number' value='$NIC' />";
}
else
	  
{
      echo "<input type='text' name='NIC_Number' />";
}
	  }
	  else
	  
{
      echo "<input type='text' name='NIC_Number' />";
}
	  ?></td>
      <td>&nbsp;</td>
      </tr>
	   <tr>
      <th height="23" bgcolor="#4AC5FF" scope="row">&nbsp;</th>
      <th height="23" bgcolor="#4AC5FF" scope="row">Access Type:</th>
      <td colspan="2" bgcolor="#4AC5FF">
	  <?php
	  $Username=$_SESSION['username'];
	  $getuser=mysql_query("SELECT * FROM user WHERE Login_Username='$Username'");
	  if($rowuser=mysql_fetch_array($getuser))
	  {
	  $Ac_Type=$rowuser['Access_Type'];
	  }
	  ?>
        <select name="Access_Type" id="select">
          <?php
		    if(!isset($_POST['Register']))
	  {
        echo '<option value="Select One">Select One</option>';
	   if($Ac_Type=="Teacher")
		  {
		  echo '<option value="'.$Ac_Type.'">'.$Ac_Type.'</option>';	   
			  echo '<option value="Teacher in Charge">Teacher in Charge</option>';
			  }
	     else if($Ac_Type=="Administrator")
		  {
		  echo '<option value="Zonal Admin">Zonal Admin</option>';
		  echo '<option value="Teacher in Charge">Teacher in Charge</option>';
		  echo '<option value="Teacher">Teacher</option>';
		   }
		   else if($Ac_Type=="Teacher in Charge")
		  {
	echo '<option value="'.$Ac_Type.'">'.$Ac_Type.'</option>';
	   echo '<option value="Teacher">Teacher</option>';
			}
else
{
		  echo '<option value="Teacher in Charge">Teacher in Charge</option>';
		  echo '<option value="Teacher">Teacher</option>';
		   }
		}
	  if(isset($_POST['Register']))
	  {
		   if($Access_Type=="")
		  {
	  if($Ac_Type!="")
		  {
		 echo '<option value="Select One">Select One</option>';
	   if($Ac_Type=="Teacher")
		  {
			  echo '<option value="'.$Ac_Type.'">'.$Ac_Type.'</option>';
	   echo '<option value="Teacher in Charge">Teacher in Charge</option>';
			  }
	     if($Ac_Type=="Administrator")
		  {
		  echo '<option value="Zonal Admin">Zonal Admin</option>';
		  echo '<option value="Teacher in Charge">Teacher in Charge</option>';
		  echo '<option value="Teacher">Teacher</option>';
		   }
		   if($Ac_Type=="Teacher in Charge")
		  {
	echo '<option value="'.$Ac_Type.'">'.$Ac_Type.'</option>';
	   echo '<option value="Teacher">Teacher</option>';
			}
			}
			else
{
		  echo '<option value="Teacher in Charge">Teacher in Charge</option>';
		  echo '<option value="Teacher">Teacher</option>';
		   }
		  }
		   if($Access_Type=="Teacher in Charge")
		  {
		  echo '<option value="'.$Access_Type.'">'.$Access_Type.'</option>';
	echo '<option value="Teacher">Teacher</option>';
			}
		  else if($Access_Type=="Teacher")
		  {
		  echo '<option value="'.$Access_Type.'">'.$Access_Type.'</option>';
	 echo '<option value="Teacher in Charge">Teacher in Charge</option>';
			}
	    else if($Access_Type=="Administrator")
		{
		echo '<option value="'.$Access_Type.'">'.$Access_Type.'</option>';
		  echo '<option value="Zonal Admin">Zonal Admin</option>';
			 echo '<option value="Teacher in Charge">Teacher in Charge</option>';
			echo '<option value="Teacher">Teacher</option>';
		}
	  }
?>
  </select>
      </td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <th height="23" bgcolor="#06AEFF" scope="row">&nbsp;</th>
      <th height="23" bgcolor="#06AEFF" scope="row">E-Mail: </th>
      <td colspan="2" bgcolor="#06AEFF">   <?php
	   if(isset($_POST['Register']))
	  {
	 $E_M=$E_Mail;
	  if(isset($E_M))
	  
{
      echo "<input type='email' name='E_Mail' value='$E_M' />";
}
else
	  
{
      echo "<input type='email' name='E_Mail' />";
}
	  }
	  else
	  
{
      echo "<input type='email' name='E_Mail' />";
}
	  ?></td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <th height="23" bgcolor="#4AC5FF" scope="row">&nbsp;</th>
      <th height="23" bgcolor="#4AC5FF" scope="row">Username:</th>
      <td colspan="2" bgcolor="#4AC5FF"> <?php
	   if(isset($_POST['Register']))
	  {
	 $L_U=$Login_Username;
	  if(isset($L_U))
	  
{
      echo "<input type='text' name='Login_Username' value='$L_U' />";
}
else
	  
{
      echo "<input type='text' name='Login_Username' />";
}
	  }
	  else
	  
{
      echo "<input type='text' name='Login_Username' />";
}
	  ?></td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <th height="23" bgcolor="#06AEFF" scope="row">&nbsp;</th>
      <th height="23" bgcolor="#06AEFF" scope="row">Password: </th>
      <td bgcolor="#06AEFF">
        <?php
	  if(isset($pwre))
	  {
      echo "<input type='password' name='Password' value='$pwre' onKeyUp='showProgress(this.value)'/>";
	  }
	  else
	  {
		  echo '<input type="password" name="Password" onKeyUp="showProgress(this.value)"/>';
	  }
	  ?>
      </td>
      <td bgcolor="#06AEFF"><div id=progress>
     </div></td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <th height="23" bgcolor="#4AC5FF" scope="row"> </th>
      <th height="23" bgcolor="#4AC5FF" scope="row">Verify your Password:</th>
      <td width="142" bgcolor="#4AC5FF"><input type="password" name="PasswordVar"/></td>
      <td width="168" bgcolor="#4AC5FF">
      
</td>
      <td> 
	  <font class="err">
	  <?php
	  if(isset($_POST['Register']))
{
      if(isset($_SESSION['errorverify']))
	{echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorverify'];
		unset($_SESSION['errorverify']);
		
	}
		if(isset($_SESSION['errorveri']))
	{echo '<img src="images/alert.jpg" width="12" height="12"/> ';
		echo $_SESSION['errorveri'];
		unset($_SESSION['errorveri']);
		
	}
}
	?>
	</font></td>
     
	<td width="6"></td>
    </tr>
    <tr>
      <th height="24" colspan="2" bgcolor="#06AEFF" scope="row">&nbsp;</th>
      <td colspan="2" bgcolor="#06AEFF">
  <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
  <label for='message'>Enter the code above here :</label><br>
  <input id="6_letters_code" name="6_letters_code" type="text"><br>
  <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <th height="43" colspan="2" scope="row">&nbsp;</th>
      <td><a href="?action=create" class="reset">Reset |</a>	         
 <input name="Register" align="middle" type="submit" value="Register" class="buttonok"/>
   </td>
      <td></td>
      <td>&nbsp;</td>
      </tr>
   
  </table></form>
  <?php
  }
  }
  }
  ?>
	</div>
    <div id="righttable_index">
<?php
if(!$_POST['Delete_Post'])
{
if((($_GET['action']=="create"&&$_SESSION['successcre']=="succ")||($_GET['action']=="acc_setting"&&$_SESSION['successacc']=="succ")||($_GET['action']=="pri_setting"&&$_SESSION['successpri']=="succ")||($_GET['action']=="forget_pw"&&$_SESSION['successfp']=="succ"))||!isset($_GET['action'])||($_GET['action']!="create"&&$_GET['action']!="forget_pw"&&$_GET['action']!="pri_setting"&&$_GET['action']!="acc_setting"))
{
	require_once ("Login/config.php");
	$arratab="";
	$delarray="";
	$sql ="SHOW TABLES FROM $db";
	$resulttable=mysql_query($sql);
while ($rowtable=mysql_fetch_row($resulttable))
{
	$tna=substr($rowtable[0],0,3);
	$sta="del";
	if(strcmp($tna,$sta)==0)
	{
			if(empty($arratab))
		{
			$arratab=$rowtable[0];
		}
		else
		{
			$arratab=$arratab.",".$rowtable[0];
		}
	}
}
$dta= str_replace(","," ",$arratab);
$delTables=explode(" ",$dta);
for($t=0;$t<count($delTables);$t++)
{
	$cherows=mysql_query("SELECT * FROM $delTables[$t]");
	if(mysql_num_rows($cherows)>0)
	{
		if(empty($delarray))
		{
			$delarray=$delTables[$t];
		}
		else
		{
		$delarray=$delarray.",".$delTables[$t];
		}
	}
}
$delarrayl=str_replace(","," ",$delarray);
$avaiTables=explode(" ",$delarrayl);
$tdt=count($avaiTables);
	?>
	   <form action="#" method="post">
    <?php
	$act=substr($_GET['action'],0,3);
	if($_SESSION['Access_Type']=="Administrator"&&$act=="del")
{
if($_GET['action']=="deletetd")
{
$selectedtab="deleted_training_details";
$Teacher_NIC=$_GET['Teacher_NIC'];
$Deleted_date=$_GET['Deleted_Date'];
$Training_Id=$_GET['Training_Id'];
   $sqlre=mysql_query("SELECT * FROM deleted_training_details WHERE Training_Id='$Training_Id' AND Deleted_date='$Deleted_date' AND Teacher_NIC='$Teacher_NIC'");
}
if($_GET['action']=="deletes")
{
$selectedtab="deleted_school";
$Deleted_date=$_GET['Deleted_Date'];
$Census_Number=$_GET['Census_Number'];
   $sqlre=mysql_query("SELECT * FROM deleted_school WHERE Census_Number='$Census_Number' AND Deleted_date='$Deleted_date'");
}
if($_GET['action']=="deletet")
{$selectedtab="deleted_teacher";
$Deleted_date=$_GET['Deleted_Date'];
$T_NIC_Number=$_GET['T_NIC_Number'];
   $sqlre=mysql_query("SELECT * FROM deleted_teacher WHERE T_NIC_Number='$T_NIC_Number' AND Deleted_date='$Deleted_date'");
}
if($_GET['action']=="deletee")
{
$selectedtab="deleted_exam";
$School_Id=$_GET['School_Id'];
   $Year=$_GET['Year'];
   $Exam_Name=$_GET['Exam_Name'];
    $sqlre=mysql_query("SELECT * FROM deleted_exam WHERE Year='$Year' AND Exam_Name='$Exam_Name' AND School_Id='$School_Id'");
}
if($_GET['action']=="deletel")
{
$selectedtab="deleted_lab";
$School_Id=$_GET['School_Id'];
   $Lab_Id=$_GET['Lab_Id'];
   $Deleted_Date=$_GET['Deleted_Date'];
   $sqlre=mysql_query("SELECT * FROM deleted_lab WHERE Lab_Id='$Lab_Id' AND Deleted_date='$Deleted_Date' AND School_Id='$School_Id'");
}
if($_GET['action']=="deletep")
{
$selectedtab="deleted_programmes";
$Programme_Id=$_GET['Programme_Id'];
$School_Id=$_GET['School_Id'];
$Year=$_GET['Year'];
$Grade=$_GET['Grade'];
   $sqlre=mysql_query("SELECT * FROM deleted_programmes WHERE Programme_Id='$Programme_Id' AND Year='$Year' AND School_Id='$School_Id' AND Grade='$Grade'");
	
}
if($_GET['action']=="deleter")
{
$selectedtab="deleted_resource_details";
$Resource_Id=$_GET['Resource_Id'];
$Deleted_Date=$_GET['Deleted_Date'];
$Serial_Number=$_GET['Serial_Number'];
 $sqlre=mysql_query("SELECT * FROM deleted_resource_details WHERE Resource_Id='$Resource_Id' AND Deleted_date='$Deleted_Date' AND Serial_Number='$Serial_Number'");
}
if($_GET['action']=="deletert")
{
$selectedtab="deleted_resource_team";
$Training_Id=$_GET['Training_Id'];
$Deleted_Date=$_GET['Deleted_Date'];
$T_NIC_Number=$_GET['T_NIC_Number'];
   $sqlre=mysql_query("SELECT * FROM deleted_resource_team WHERE T_NIC_Number='$T_NIC_Number' AND Training_Id='$Training_Id' AND Deleted_date='$Deleted_Date'");
	
}
if($_GET['action']=="delete")
{
$selectedtab="deleted_competition";
$School_Id=$_GET['School_Id'];
   $Competition_Id=$_GET['Competition_Id'];
   $Date=$_GET['Date'];
   $sqlre=mysql_query("SELECT * FROM deleted_competition WHERE Competition_Id='$Competition_Id' AND Date='$Date' AND School_Id='$School_Id'");
	
}
$cnamearray="";
	if(mysql_num_rows($sqlre)!=0)
	{
	$qucol="SHOW COLUMNS FROM $selectedtab";
$resultcol=mysql_query($qucol);
$totcol=mysql_num_rows($resultcol);
	$gettable="SELECT * FROM $selectedtab";
$gettables=mysql_query($gettable);
while($rowcolu=mysql_fetch_row($resultcol))
{
if(empty($arratab))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
}
	$cnamearray=explode(",",$colnamearray);
	if($totcol>11)
	{
	echo '<div style="width:134%; height:400px; overflow-Y:scroll; ">';
	}
      echo '<table width="134%" border="0" class="tablefontvd">';
	if($row=mysql_fetch_array($sqlre))
  {
  if($selectedtab=="deleted_lab")
	{
	for($cv=1;$cv<=10;$cv++)
	{
	$val=$cnamearray[$cv];
	$valu=$row[$val];
	$th_cname= str_replace("_"," ",$val);
    echo "<tr height='34'><th>".$th_cname.":</th><td><input type='text' name='$val' value='$valu'/></td></tr>";
	}
	}
	else if($selectedtab=="deleted_teacher")
	{
	for($cv=1;$cv<=21;$cv++)
	{
	$val=$cnamearray[$cv];
	$valu=$row[$val];
	$th_cname= str_replace("_"," ",$val);
    echo "<tr height='34'><th>".$th_cname.":</th><td><input type='text' name='$val' value='$valu'/></td></tr>";
	}
	}
	else
	{
     for($cv=1;$cv<=$totcol;$cv++)
	{
	$val=$cnamearray[$cv];
	$valu=$row[$val];
	$th_cname= str_replace("_"," ",$val);
    echo "<tr height='34'><th>".$th_cname.":</th><td><input type='text' name='$val' value='$valu'/></td></tr>";
	}
	}
		echo '<tr height="34"><th><a href="index.php"><img src="images/back.jpg"/></a></th>';
		echo '<td>';
		echo "<input type='submit' name='Delete' value='Accept'/>";
		echo '</td>';
      echo '</tr>';
	 
   }
    echo '</table>';
	if($totcol>11)
	{
	echo '</div>';
	}
}
}
?>
 </form>  
    
    <form action="#" method="post">
    <?php
	if($_SESSION['Access_Type']=="Administrator"&&$act=="add")
{
if($_GET['action']=="addtd")
{
$selectedtab="deleted_training_details";
$Teacher_NIC=$_GET['Teacher_NIC'];
$Deleted_date=$_GET['Deleted_Date'];
$Training_Id=$_GET['Training_Id'];
   $sqlre=mysql_query("SELECT * FROM deleted_training_details WHERE Training_Id='$Training_Id' AND Deleted_date='$Deleted_date' AND Teacher_NIC='$Teacher_NIC'");
}
if($_GET['action']=="adds")
{
$selectedtab="deleted_school";
$Deleted_date=$_GET['Deleted_Date'];
$Census_Number=$_GET['Census_Number'];
 $sqlre=mysql_query("SELECT * FROM deleted_school WHERE Census_Number='$Census_Number' AND Deleted_date='$Deleted_date'");
}
if($_GET['action']=="addt")
{$selectedtab="deleted_teacher";
$Deleted_date=$_GET['Deleted_Date'];
$T_NIC_Number=$_GET['T_NIC_Number'];
   $sqlre=mysql_query("SELECT * FROM deleted_teacher WHERE T_NIC_Number='$T_NIC_Number' AND Deleted_date='$Deleted_date'");
}
if($_GET['action']=="adde")
{$selectedtab="deleted_exam";
$School_Id=$_GET['School_Id'];
   $Year=$_GET['Year'];
   $Exam_Name=$_GET['Exam_Name'];
    $sqlre=mysql_query("SELECT * FROM deleted_exam WHERE Year='$Year' AND Exam_Name='$Exam_Name' AND School_Id='$School_Id'");
}
if($_GET['action']=="addl")
{$selectedtab="deleted_lab";
$School_Id=$_GET['School_Id'];
   $Lab_Id=$_GET['Lab_Id'];
   $Deleted_Date=$_GET['Deleted_Date'];
   $sqlre=mysql_query("SELECT * FROM deleted_lab WHERE Lab_Id='$Lab_Id' AND Deleted_date='$Deleted_Date' AND School_Id='$School_Id'");
}
if($_GET['action']=="addp")
{
$selectedtab="deleted_programmes";
$Programme_Id=$_GET['Programme_Id'];
$School_Id=$_GET['School_Id'];
$Year=$_GET['Year'];
$Grade=$_GET['Grade'];
   $sqlre=mysql_query("SELECT * FROM deleted_programmes WHERE Programme_Id='$Programme_Id' AND Year='$Year' AND School_Id='$School_Id' AND Grade='$Grade'");
	
}
if($_GET['action']=="addr")
{$selectedtab="deleted_resource_details";
$Resource_Id=$_GET['Resource_Id'];
$Deleted_Date=$_GET['Deleted_Date'];
$Serial_Number=$_GET['Serial_Number'];
   $sqlre=mysql_query("SELECT * FROM deleted_resource_details WHERE Resource_Id='$Resource_Id' AND Deleted_date='$Deleted_Date' AND Serial_Number='$Serial_Number'");
}
if($_GET['action']=="addrt")
{$selectedtab="deleted_resource_team";
$Training_Id=$_GET['Training_Id'];
$Deleted_Date=$_GET['Deleted_Date'];
$T_NIC_Number=$_GET['T_NIC_Number'];
   $sqlre=mysql_query("SELECT * FROM deleted_resource_team WHERE T_NIC_Number='$T_NIC_Number' AND Training_Id='$Training_Id' AND Deleted_date='$Deleted_Date'");
	
}
if($_GET['action']=="add")
{$selectedtab="deleted_competition";
$School_Id=$_GET['School_Id'];
   $Competition_Id=$_GET['Competition_Id'];
   $Date=$_GET['Date'];
   $sqlre=mysql_query("SELECT * FROM deleted_competition WHERE Competition_Id='$Competition_Id' AND Date='$Date' AND School_Id='$School_Id'");
	
}
$cnamearray="";
	if(mysql_num_rows($sqlre)!=0)
	{
	$colnamearray="";
	$qucol="SHOW COLUMNS FROM $selectedtab";
$resultcol=mysql_query($qucol);
$totcol=mysql_num_rows($resultcol);
while($rowcolu=mysql_fetch_row($resultcol))
{
if(empty($arratab))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
}
	$gettable="SELECT * FROM $selectedtab";
$gettables=mysql_query($gettable);
	$cnamearray=explode(",",$colnamearray);
	if($totcol>11)
	{
	echo '<div style="width:134%; height:400px; overflow-Y:scroll; ">';
	}
      echo '<table width="134%" border="0" class="tablefontvd">';
	if($row=mysql_fetch_array($sqlre))
  {
  if($selectedtab=="deleted_lab")
	{
	for($cv=1;$cv<=10;$cv++)
	{
	$val=$cnamearray[$cv];
	$valu=$row[$val];
    $th_cname= str_replace("_"," ",$val);
    echo "<tr><th height='34'>".$th_cname.":</th><td><input type='text' name='$val' value='$valu'/></td></tr>";
	}
	}
	else if($selectedtab=="deleted_teacher")
	{
	for($cv=1;$cv<=21;$cv++)
	{
	$val=$cnamearray[$cv];
	$valu=$row[$val];
    $th_cname= str_replace("_"," ",$val);
    echo "<tr><th height='34'>".$th_cname.":</th><td><input type='text' name='$val' value='$valu'/></td></tr>";
	}
	}
	else
	{
     for($cv=1;$cv<=$totcol;$cv++)
	{
	$val=$cnamearray[$cv];
	$valu=$row[$val];
    $th_cname= str_replace("_"," ",$val);
    echo "<tr><th height='34'>".$th_cname.":</th><td><input type='text' name='$val' value='$valu'/></td></tr>";
	}
	}
		echo '<tr><th height="34"><a href="index.php"><img src="images/back.jpg"/></a></th>';
		echo '<td>';
		echo "<input type='submit' name='Add' value='Do not Accept'/>";
		echo '</td>';
      echo '</tr>';
	 
   }
    echo '</table>';
	if($totcol>11)
	{
	echo '</div>';
	}
}
}
?>
  </form>  
     <form action="#" method="post">
    <?php
	if($_SESSION['Access_Type']=="Administrator")
	{
	$selectedtab=$avaiTables[0];
	if(!isset($_GET['action'])||isset($current_table))
		{
		echo '<div id="DelTable">';
		if($selectedtab!="")
		{
	$sqlta=mysql_query("SELECT * FROM $selectedtab");
	for($t=0;$t<count($avaiTables);$t++)
{
if($avaiTables[$t]==$selectedtab)
{
$text=ucwords(substr(str_replace("_"," ",$avaiTables[$t]),7));
echo '<font color="red">'.$text."</font>|";
}
else
{
$text=ucwords(substr(str_replace("_"," ",$avaiTables[$t]),7));
echo '<font color="#00000">'.$text."</font>|";
}
}
if(mysql_num_rows($sqlta)!=0)
{
$gettable="SELECT * FROM $selectedtab";
$gettables=mysql_query($gettable);
echo "<input type='hidden' name='delTable' value='$avaiTables[1]'/>";
echo '<div style="width:134%; overflow-x:scroll;">';
echo '<table width="134%" border="1" class="tablefontv">
<tr  bgcolor="#6AB5FF">
<td width="20">Drop</td>
<td width="20">Re put</td>';
$que="SHOW COLUMNS FROM $selectedtab";
$resultcol=mysql_query($que);
$totcol=mysql_num_rows($resultcol);
$colnamearray="";
if($selectedtab=="deleted_lab")
	{
	for($cv=0;$cv<10;$cv++)
	{
	if($rowcolu=mysql_fetch_row($resultcol))
{
if(empty($arratab))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
$cname=str_replace("_"," ",$rowcolu[0]);
echo '<td>'.$cname.'</td>';
}
	}
	}
	else if($selectedtab=="deleted_teacher")
	{
	for($cv=0;$cv<21;$cv++)
	{
	if($rowcolu=mysql_fetch_row($resultcol))
{
if(empty($arratab))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
$cname=str_replace("_"," ",$rowcolu[0]);
echo '<td>'.$cname.'</td>';
}
	}
	}
	else
	{
for($i=0;$i<$totcol;$i++)
{
if($rowcolu=mysql_fetch_row($resultcol))
{
if(empty($arratab))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
$cname=str_replace("_"," ",$rowcolu[0]);
echo '<td>'.$cname.'</td>';
}
}
}
echo '</tr>';
	while($row=mysql_fetch_array($sqlta))
	{
echo '<tr bgcolor="#999999">';
if($selectedtab=="deleted_training_details")
{
$s=$row['Teacher_NIC'];
$d=$row['Deleted_date'];
$c=$row['Training_Id'];
	?>
	<td width="29"><a href="index.php?action=deletetd&Training_Id=<?php echo $c; ?>&Teacher_NIC=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="29"><a href="index.php?action=addtd&Training_Id=<?php echo $c; ?>&Teacher_NIC=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
	}
	if($selectedtab=="deleted_school")
{
$d=$row['Deleted_date'];
$c=$row['Census_Number'];
	?>
	<td width="29"><a href="index.php?action=deletes&Census_Number=<?php echo $c; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="29"><a href="index.php?action=adds&Census_Number=<?php echo $c; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
	}
	if($selectedtab=="deleted_teacher")
{
$d=$row['Deleted_date'];
$c=$row['T_NIC_Number'];
	?>
	<td width="29"><a href="index.php?action=deletet&T_NIC_Number=<?php echo $c; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="29"><a href="index.php?action=addt&T_NIC_Number=<?php echo $c; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
	}
if($selectedtab=="deleted_competition")
{
$s=$row['School_Id'];
$d=$row['Date'];
$c=$row['Competition_Id'];
	?>
	<td width="29"><a href="index.php?action=delete&Competition_Id=<?php echo $c; ?>&School_Id=<?php echo $s; ?>&Date=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="29"><a href="index.php?action=add&Competition_Id=<?php echo $c; ?>&School_Id=<?php echo $s; ?>&Date=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
	}
	if($selectedtab=="deleted_exam")
{
$s=$row['School_Id'];
$d=$row['Year'];
$c=$row['Exam_Name'];
	?>
	<td width="20"><a href="index.php?action=deletee&Exam_Name=<?php echo $c; ?>&School_Id=<?php echo $s; ?>&Year=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="20"><a href="index.php?action=adde&Exam_Name=<?php echo $c; ?>&School_Id=<?php echo $s; ?>&Year=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
}
if($selectedtab=="deleted_programmes")
{
$s=$row['School_Id'];
$p=$row['Programme_Id'];
$d=$row['Year'];
$g=$row['Grade'];
	?>
	<td width="20"><a href="index.php?action=deletep&Grade=<?php $g; ?>&School_Id=<?php $s; ?>&Programme_Id=<?php echo $p; ?>&Year=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="20"><a href="index.php?action=addp&Grade=<?php $g; ?>&School_Id=<?php $s; ?>&Programme_Id=<?php echo $p; ?>&Year=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
}
if($selectedtab=="deleted_resource_details")
{
$s=$row['Resource_Id'];
$d=$row['Deleted_date'];
$c=$row['Serial_Number'];
	?>
	<td width="20"><a href="index.php?action=deleter&Serial_Number=<?php echo $c; ?>&Resource_Id=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="20"><a href="index.php?action=addr&Serial_Number=<?php echo $c; ?>&Resource_Id=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
}
if($selectedtab=="deleted_resource_team")
{
$s=$row['Training_Id'];
$d=$row['Deleted_date'];
$c=$row['T_NIC_Number'];
	?>
	<td width="20"><a href="index.php?action=deletert&T_NIC_Number=<?php echo $c; ?>&Training_Id=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="20"><a href="index.php?action=addrt&T_NIC_Number=<?php echo $c; ?>&Training_Id=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
}
if($selectedtab=="deleted_lab")
{
$s=$row['School_Id'];
$d=$row['Deleted_date'];
$c=$row['Lab_Id'];
	?>
	<td width="29"><a href="index.php?action=deletel&Lab_Id=<?php echo $c; ?>&School_Id=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_deltbl.png" width="25"/></a></td>
    <td width="29"><a href="index.php?action=addl&Lab_Id=<?php echo $c; ?>&School_Id=<?php echo $s; ?>&Deleted_Date=<?php echo $d; ?>"><img src="images/b_insrow.png" width="25"/></a></td>
    <?php
}
	$cnamearray=explode(",",$colnamearray);
	if($row=mysql_fetch_array($gettables))
	{
	if($selectedtab=="deleted_lab")
	{
	for($cv=1;$cv<=10;$cv++)
	{
	$val=$cnamearray[$cv];
	echo '<td>'.$row[$val].'</td>';
	}
	}
	else if($selectedtab=="deleted_teacher")
	{
	for($cv=1;$cv<=21;$cv++)
	{
	$val=$cnamearray[$cv];
	echo '<td>'.$row[$val].'</td>';
	}
	}
	else
	{
	for($cv=1;$cv<=$totcol;$cv++)
	{
	$val=$cnamearray[$cv];
	echo '<td>'.$row[$val].'</td>';
	}	
	}
	}
     echo '</tr>';
}
   echo "</table>";
   echo '</div>';
}
if(count($avaiTables)>1)
{
?>
<input type="button" class="submit" onClick="showDeltable(delTable.value)"/>
<?php
}

}
}
}
 ?>
</form> 

 <br/>
 <?php
 if($email=="Yes")
 {
	 echo "<font color='#000000'>Send mail</font>";
?>
 <br/>
<form name="myform" action="#" method="POST" onSubmit="return submitmail()">
<?php
$Accessed_By=$_SESSION['Accessed_By'];
$getmail=mysql_query("SELECT * FROM user WHERE NIC_Number='$Accessed_By'");
unset($_SESSION['Accessed_By']);
if($rowmail=mysql_fetch_array($getmail))
{
	$mailid=$rowmail['E_Mail'];
}
$from=$_SESSION['Mail_Id'];
$to=$mailid;
$subject="Hi";
$message = "";
?>
			<TABLE CELLSPACING=0 CELLPADDING=0 BORDER="1" class="tablefontv">
				<TR>
					<TD width="61" height="28">To: </TD>
			  <TD width="330"><?php
              echo "<input type='text' name='MailTo' size='55' value='$to'/>";
			  ?></TD></TR>
				
				<TR>
				  <TD height="30">From: </TD>
				  <TD> <?php
              echo "<input type='text' name='MailFrom' size='55' value='$from'/>";
			  ?></TD>
			  </TR>
				<TR>
					<TD height="30">Subject:</TD>
			  <TD>
              <?php
              echo "<input type='text' name='Subject' size='55' value='$subject'/>";
			  ?></TD></TR>
				<TR>
				<TD>Message: </TD>
					<TD>
                    <form action="ckeditor/sample_posteddata.php" method="post">
				<textarea cols="80" id="editor1" name="Message" rows="5"></textarea>
			<script type="text/javascript">
			
			CKEDITOR.replace( 'editor1',
				{
					extraPlugins : 'bbcode',
										removePlugins : 'bidi,button,dialogadvtab,div,filebrowser,flash,format,forms,horizontalrule,iframe,indent,justify,liststyle,pagebreak,showborders,stylescombo,table,tabletools,templates',
					
					disableObjectResizing : true,
					fontSize_sizes : "30/30%;50/50%;100/100%;120/120%;150/150%;200/200%;300/300%",
					toolbar :
					[
						['Bold', 'Italic','Underline'],
						['Font','FontSize'],
						['TextColor'],
						['NumberedList','BulletedList','-','Blockquote']
					]
			} );

			</script>
			</form>
</TD></TR>
				<TR>
					<TD align='right' COLSPAN=2>
                    <input type='submit' name='SendMail' value='Send'/>
                    </TD></TR>
			</TABLE>
</form>
 <?php
  $email="";
 }
 echo '</div>';
 }
 ?>
</div>

</div>
<?php
}
?>
</div>      
</div>
<?php
if(loggedin()||($_GET['action']=="create"||$_GET['action']=="forget_pw"||$_GET['action']=="acc_setting"||$_GET['action']=="pri_setting"))
{
?>
<div id="sidebar1">
		
  <div id="updates" class="boxed">
			<h2 class="title">Recent Updates</h2>
			<div class="content">
			<ul>
			<div id="posts">
					<?php
				$get_posts=mysql_query("SELECT * FROM posts");
				$num=mysql_num_rows($get_posts);
				if($get_posts)
				{
				for($i=0;$i<4;$i++)
				{
				if($rowpost=mysql_fetch_array($get_posts))
				{
				echo '<li><h3>'.$rowpost['Event_Date'].'</h3>';
				echo '<p>'.$rowpost['News'].'&#8230;</p></li>';
				}
				}
				}
				if(mysql_num_rows($get_posts)>4)
				{
				$ind=5;
				?>
				<img src="images/next.png" align="right" onClick="showNextPosts(<?php echo $ind;?>)"/>
				<?php
              	}
				?>
				</div>
                <li><table>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
</td></tr></table>
<?php
if(loggedin()||(isset($_GET['action'])&&(isset($_SESSION['successcre'])||isset($_SESSION['successacc'])||isset($_SESSION['successpri'])||isset($_SESSION['successfp']))))
{
?>
<form action="#" method="post">
<table>
<tr>
<td><input type="button" name="Add_Post" class="okbutton" value="Add new Post" onClick="popup_show('popup', 'popup_drag', 'popup_exit', 'screen-center',0,0);"/>
</td><td>&nbsp;</td>
<td>
<?php
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher")
{
?>
<input type="submit" name="Delete_Post" value="Delete a Post" class="okbutton"/>
 <?php
}
?>
</td></tr><tr><td colspan="4">
<font class="err">
<?php
if(isset($_SESSION['del']))
{
echo '<img src="images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['del'];
unset($_SESSION['del']);
}

?>
</font>
</td></tr>
</table></form>
<div class="sample_popup" id="popup" style="display: none;">
<div class="menu_form_header_news" id="popup_drag">
<img class="menu_form_exit" id="popup_exit" src="images/form_exit.png" alt="exit" />
&nbsp;&nbsp;&nbsp;&nbsp;<font size="4">Add Post</font>
</div>

<div class="menu_form_body_news">
<form action="#" method="post" enctype="multipart/form-data">
          		<TABLE class="tablefontv">
				<TR>
					<TD>Date of the Event: </TD>
			  <TD><?php
          echo "<input type='text' name='Date' size='45' class='inputDate' value='$t_d' id='inputDate'/>";
		  ?></TD></TR>				
				<TR>
					<TD align="top">News:</TD>
			  <TD>
         <form action="ckeditor/sample_posteddata.php" method="post">
         <textarea cols="25" id="editor1" name="News" rows="5">This is some [b]sample text[/b]</textarea>
			<script type="text/javascript">
			
			CKEDITOR.replace( 'editor1',
				{
					extraPlugins : 'bbcode',
					removePlugins : 'bidi,button,dialogadvtab,div,filebrowser,flash,format,forms,horizontalrule,iframe,indent,justify,liststyle,pagebreak,showborders,stylescombo,table,tabletools,templates',
					
					disableObjectResizing : true,
					fontSize_sizes : "30/30%;50/50%;100/100%;120/120%;150/150%;200/200%;300/300%",
					toolbar :
					[
						['Bold', 'Italic','Underline'],
						['Font','FontSize'],
						['TextColor'],
						['NumberedList','BulletedList','-','Blockquote']
					]
			} );

			</script>
			</form> </TD></TR>
				<TR>
					<TD>
		  </TD>
		  <TD>	
          <input type="submit" name="AddNews" value="Post"/>		 
		  </TD></TR>
		</TABLE>
        </form>
</div>
</div>
<?php
}
?>
</li>
</ul> 
</div>
<br/>
</div>
<div class="createnew">
			<h2 class="title"><a href="?action=create"></a>
			<table width="245" border="0" align="center">
			  <tr>
			    <td width="73">&nbsp;</td>
			    <td width="99" bgcolor="#BB0000" align="center"><a href="?action=create">Sign Up</a></td>
			    <td width="73">&nbsp;</td>
		      </tr>
		  </table>
        </div>
	<?php
unset($_SESSION['successcre']);
unset($_SESSION['successacc']);
unset($_SESSION['successpri']);
unset($_SESSION['successfp']);
?>
</div>
<?php
}
include_once 'footer.php';
?>
</body>
</html>